• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Smarty/libs/plugins/shared.make_timestamp.php

00001 <?php
00016 function smarty_make_timestamp($string)
00017 {
00018     if(empty($string)) {
00019         // use "now":
00020         $time = time();
00021 
00022     } elseif (preg_match('/^\d{14}$/', $string)) {
00023         // it is mysql timestamp format of YYYYMMDDHHMMSS?            
00024         $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
00025                        substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
00026         
00027     } elseif (is_numeric($string)) {
00028         // it is a numeric string, we handle it as timestamp
00029         $time = (int)$string;
00030         
00031     } else {
00032         // strtotime should handle it
00033         $time = strtotime($string);
00034         if ($time == -1 || $time === false) {
00035             // strtotime() was not able to parse $string, use "now":
00036             $time = time();
00037         }
00038     }
00039     return $time;
00040 
00041 }
00042 
00043 /* vim: set expandtab: */
00044 
00045 ?>

Generated on Thu Apr 19 2012 17:01:16 for openbiz by  doxygen 1.7.2