我需要将一个PHP中的feed日期/时间转换为Unix时间戳。
从2010-04-13T10:00:00.000-04:00
-> Unix
我一直在尝试使用date()
和strtotime()
,但没有成功。
$dt=new DateTime("2010-04-13T10:00:00.000-04:00");
echo $dt->format('U');
试试这个:
$time = strtotime(preg_replace('/(T|\.\d{3})/', ' ', '2010-04-13T10:00:00.000-04:00'));
在这里,我使用了preg_replace
函数将T
和毫秒替换为单个空格。