3 * template_lite date modifier plugin
7 * Purpose: formats a date given a UNIX timestamp, based on the
10 * - string: input date string
11 * - format: date format for output
12 * - default_date: default date if $string is empty
14 function tpl_modifier_date($string, $format="r", $default_date=null)
18 return date($format, tpl_make_timestamp($string));
20 elseif (isset($default_date) && $default_date != '')
22 return date($format, tpl_make_timestamp($default_date));
30 if(!function_exists('tpl_make_timestamp'))
32 function tpl_make_timestamp($string)
38 $time = strtotime($string);
39 if (is_numeric($time) && $time != -1)
44 // is mysql timestamp format of YYYYMMDDHHMMSS?
45 if (is_numeric($string) && strlen($string) == 14)
47 $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));
51 // couldn't recognize it, try to return a time
52 $time = (int) $string;