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>
14 * @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
17 function smarty_make_timestamp($string)
22 } elseif ($string instanceof DateTime) {
23 return $string->getTimestamp();
24 } elseif (strlen($string) == 14 && ctype_digit($string)) {
25 // it is mysql timestamp format of YYYYMMDDHHMMSS?
26 return mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
27 substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
28 } elseif (is_numeric($string)) {
29 // it is a numeric string, we handle it as timestamp
32 // strtotime should handle it
33 $time = strtotime($string);
34 if ($time == -1 || $time === false) {
35 // strtotime() was not able to parse $string, use "now":