-
- function date_format2($string, $format='%b %e, %y', $default_date=null)
- {
- if (substr(php教程_os,0,3) == 'win') {
- $_win_from = array ('%e', '%t', '%d');
- $_win_to = array ('%#d', '%h:%m:%s', '%m/%d/%y');
- $format = str_replace($_win_from, $_win_to, $format);
- }
- if($string != '') {
- return strftime($format, smarty_make_timestamp($string));
- } elseif (isset($default_date) && $default_date != '') {
- return strftime($format, smarty_make_timestamp($default_date));
- } else {
- return;
- }
- }
- function smarty_make_timestamp($string){
- if(emptyempty($string)) {
- $string = "now";
- }
- $time = strtotime($string);
- if (is_numeric($time) && $time != -1)
- return $time;
- if (preg_match('/^d{14}$/', $string)) {
- $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));
-
- return $time;
- }
- $time = (int) $string;
- if ($time > 0)
- return $time;
- else
- return time();
- }
|