将唯一时间戳转换为时间

时间:2014-08-01 17:49:06

标签: php

我需要有关此特定代码的帮助。如何让php strtotime20140802T00: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"

1 个答案:

答案 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
相关问题