mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-05 08:40:54 +02:00
32 lines
874 B
PHP
32 lines
874 B
PHP
![]() |
<?php
|
||
|
|
||
|
/*======================================================================*\
|
||
|
Function: smarty_make_timestamp
|
||
|
Purpose: used by other smarty functions to make a timestamp
|
||
|
from a string.
|
||
|
\*======================================================================*/
|
||
|
function smarty_make_timestamp($string)
|
||
|
{
|
||
|
if(empty($string)) {
|
||
|
$string = "now";
|
||
|
}
|
||
|
$time = strtotime($string);
|
||
|
if (is_numeric($time) && $time != -1)
|
||
|
return $time;
|
||
|
|
||
|
// is mysql timestamp format of YYYYMMDDHHMMSS?
|
||
|
if (is_numeric($string) && strlen($string) == 14) {
|
||
|
$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));
|
||
|
|
||
|
return $time;
|
||
|
}
|
||
|
|
||
|
// can't decipher, just return it
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
/* vim: set expandtab: */
|
||
|
|
||
|
?>
|