avoid preg for string match

This commit is contained in:
monte.ohrt
2011-01-17 21:49:19 +00:00
parent d494d0db22
commit 2d75fb0098

View File

@@ -22,7 +22,7 @@ function smarty_make_timestamp($string)
return time();
} elseif ($string instanceof DateTime) {
return $string->getTimestamp();
} elseif (preg_match('/^\d{14}$/', $string)) {
} elseif (ctype_digit($string) && strlen($string)==14) {
// it is mysql timestamp format of YYYYMMDDHHMMSS?
return 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));
@@ -40,4 +40,4 @@ function smarty_make_timestamp($string)
}
}
?>
?>