16
16
function smarty_make_timestamp($string)
18
18
if(empty($string)) {
21
$time = strtotime($string);
22
if (is_numeric($time) && $time != -1)
25
// is mysql timestamp format of YYYYMMDDHHMMSS?
26
if (preg_match('/^\d{14}$/', $string)) {
27
$time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
28
substr($string,4,2),substr($string,6,2),substr($string,0,4));
33
// couldn't recognize it, try to return a time
34
$time = (int) $string;
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));
27
} elseif (is_numeric($string)) {
28
// it is a numeric string, we handle it as timestamp
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":
41
43
/* vim: set expandtab: */