Source for file shared.make_timestamp.php

Documentation is available at shared.make_timestamp.php

  1. <?php
  2. /**
  3.  * Smarty shared plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8.  
  9. /**
  10.  * Function: smarty_make_timestamp<br>
  11.  * Purpose:  used by other smarty functions to make a timestamp
  12.  *           from a string.
  13.  * @author   Monte Ohrt <monte at ohrt dot com>
  14.  * @param string 
  15.  * @return string 
  16.  */
  17. function smarty_make_timestamp($string)
  18. {
  19.     if(empty($string)) {
  20.         // use "now":
  21.         $time time();
  22.  
  23.     elseif (preg_match('/^\d{14}$/'$string)) {
  24.         // it is mysql timestamp format of YYYYMMDDHHMMSS?            
  25.         $time mktime(substr($string82),substr($string102),substr($string122),
  26.                        substr($string42),substr($string62),substr($string04));
  27.         
  28.     elseif (is_numeric($string)) {
  29.         // it is a numeric string, we handle it as timestamp
  30.         $time = (int)$string;
  31.         
  32.     else {
  33.         // strtotime should handle it
  34.         $time strtotime($string);
  35.         if ($time == -|| $time === false{
  36.             // strtotime() was not able to parse $string, use "now":
  37.             $time time();
  38.         }
  39.     }
  40.     return $time;
  41.  
  42. }
  43.  
  44. /* vim: set expandtab: */
  45.  
  46. ?>

Documentation generated on Sun, 09 Mar 2008 23:53:02 -0300 by phpDocumentor 1.4.0

SourceForge.net Logo Support This Project