mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
avoid preg for string match
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user