init
[garradin.git] / include / libs / template_lite / plugins / shared.make_timestamp.php
1 <?php
2 /**
3 * template_lite tpl_create_timestamp function
4 *
5 * Taken from the original Smarty
6 * http://smarty.php.net
7 *
8 */
9 function tpl_make_timestamp($string)
10 {
11 if(empty($string))
12 {
13 $string = "now";
14 }
15 $time = strtotime($string);
16 if (is_numeric($time) && $time != -1)
17 {
18 return $time;
19 }
20
21 // is mysql timestamp format of YYYYMMDDHHMMSS?
22 if (is_numeric($string) && strlen($string) == 14)
23 {
24 $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),substr($string,4,2),substr($string,6,2),substr($string,0,4));
25 return $time;
26 }
27
28 // couldn't recognize it, try to return a time
29 $time = (int) $string;
30 if ($time > 0)
31 {
32 return $time;
33 }
34 else
35 {
36 return time();
37 }
38 }
39
40 ?>