Kyberia v2.3 - 1st revision from SVN (Without patches of kyberia.sk team)
[mirrors/Kyberia-bloodline.git] / smarty / Smarty-2.6.10 / libs / plugins / 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 * @param string
14 * @return string
15 */
16 function smarty_make_timestamp($string)
17 {
18 if(empty($string)) {
19 // use "now":
20 $time = time();
21
22 } elseif (preg_match('/^\d{14}$/', $string)) {
23 // it is mysql timestamp format of YYYYMMDDHHMMSS?
24 $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
25 substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
26
27 } elseif (is_numeric($string)) {
28 // it is a numeric string, we handle it as timestamp
29 $time = (int)$string;
30
31 } else {
32 // strtotime should handle it
33 $time = strtotime($string);
34 if ($time == -1 || $time === false) {
35 // strtotime() was not able to parse $string, use "now":
36 $time = time();
37 }
38 }
39 return $time;
40
41 }
42
43 /* vim: set expandtab: */
44
45 ?>
This page took 0.275905 seconds and 4 git commands to generate.