6 * @subpackage PluginsShared
10 * Function: smarty_make_timestamp<br>
11 * Purpose: used by other smarty functions to make a timestamp from a string.
13 * @author Monte Ohrt <monte at ohrt dot com>
15 * @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
19 function smarty_make_timestamp($string)
24 } elseif ($string instanceof DateTime) {
25 return $string->getTimestamp();
26 } elseif (strlen($string) == 14 && ctype_digit($string)) {
27 // it is mysql timestamp format of YYYYMMDDHHMMSS?
28 return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2),
29 substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4));
30 } elseif (is_numeric($string)) {
31 // it is a numeric string, we handle it as timestamp
34 // strtotime should handle it
35 $time = strtotime($string);
36 if ($time == - 1 || $time === false) {
37 // strtotime() was not able to parse $string, use "now":