2013-02-23 72 views
-1

我遇到了一个奇怪的问题,它只针对我的数据库中日期为2014-01-01的日期。我正在重新设定日期的格式,但PHP将它们显示为JAN 13.所有其他日期在不同月份都显示正常。这怎么可能?为什么PHP显示2013-01-01的日期与2013年1月一样

我的功能:

public function exp_date($date) { 
    // Hide wrong dates 
    if ($date == '0000-00-00' || $date == '1969-12-31') { 
     $out = ""; 
    } else { 
     $out = strtoupper(date('M y', strtotime($date))); 
    } 

    if ($out == 'DEC 69' || $out == 'JAN 70') { 
     $out2 = ""; 
    } else { 
     $out2 = $out; 
    } 
    return $out2; 
} 
+0

'PHP -r“回声日期( 'M Y',的strtotime( '2014年1月1日')) ;'''打印'1月14日'我..什么是'$ date'? – 2013-02-23 01:21:03

+0

'var_dump(date('M y',strtotime(“2014-01-01”)));'give me'string(6)“Jan 14”' – sachleen 2013-02-23 01:21:08

+0

I get Jan 14 http://codepad.viper- 7/24SSI9 – 2013-02-23 01:22:08

回答

0

删除您的来电strtotime

$out = strtoupper(date('M y', $date)); 
相关问题