我需要有关此特定代码的帮助。如何让php strtotime
将20140802T00:00:00
识别为正确的时间字符串?
$new_exp = date('M-d-y',strtotime($condat['_CouponExpiration']));
echo $conDat['_CouponExpiration'] . ' ' .$new_exp;
// 20140802T00:00:00 Jan-01-70
// $newexp should return "Aug-02-14"
答案 0 :(得分:1)
使用str_replace替换" T"有空间,这应该解决问题:
<?
$D1="20140802T00:00:00";
$D2=str_replace("T", " ", $D1);
print $D1 . "\n";
print $D2 . "\n";
print strtotime($D2) . "\n";
print date('M-d-y', strtotime($D2)) . "\n";
?>
产生
20140802T00:00:00
20140802 00:00:00
1406952000
Aug-02-14