[ Index ]

krapohl.info

title

Body

[close]

/pnincludes/Smarty/plugins/ -> shared.make_timestamp.php (source)

   1  <?php
   2  
   3  /*======================================================================*\
   4      Function: smarty_make_timestamp
   5      Purpose:  used by other smarty functions to make a timestamp
   6                from a string.
   7  \*======================================================================*/
   8  function smarty_make_timestamp($string)
   9  {
  10      if(empty($string)) {
  11          $string = "now";
  12      }
  13      $time = strtotime($string);
  14      if (is_numeric($time) && $time != -1)
  15          return $time;
  16  
  17      // is mysql timestamp format of YYYYMMDDHHMMSS?
  18      if (is_numeric($string) && strlen($string) == 14) {
  19          $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
  20                 substr($string,4,2),substr($string,6,2),substr($string,0,4));
  21  
  22          return $time;
  23      }
  24  
  25      // couldn't recognize it, try to return a time
  26      $time = (int) $string;
  27      if ($time > 0)
  28          return $time;
  29      else
  30          return time();
  31  }
  32  /* vim: set expandtab: */
  33  
  34  ?>


Generated: Wed Feb 16 22:40:07 2005 Cross-referenced by PHPXref 0.6