Code: Select all
function smarty_make_timestamp($string)
{
$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 decipher, must be timestamp already?
return $string;
}Code: Select all
$ php --version
PHP 5.2.9 (cli) (built: Apr 17 2009 03:42:25)
$php -r "var_dump(strtotime( 1252609023 ));"
bool(false)
Code: Select all
php -v
PHP 4.3.2 (cgi)
$ php -f test.php
int(-1)Code: Select all
# php --version
PHP 5.2.8 (cli) (built: Aug 11 2009 17:57:58)
#php -r "var_dump(strtotime( 1252609023 ));"
int(222592906380)