Php 时间返回错误的一天

Php 时间返回错误的一天,php,xml-parsing,Php,Xml Parsing,当使用以下命令时 echo date('D',strtotime("2013-06-16T06:00:00-07:00")); echo date('D',strtotime("2013-06-16T18:00:00-07:00")); 第一个返回Sun,第二个返回Mon。我真的不知道为什么或如何纠正!日期:“2013-06-16T06:00:00-07:00”是我从XML文件中检索的数据。时间戳在末尾对UTC进行了更正,但不确定这是否产生了错误 感谢您的帮助。这是因为日期表示时间在“设置”中

当使用以下命令时

echo date('D',strtotime("2013-06-16T06:00:00-07:00"));
echo date('D',strtotime("2013-06-16T18:00:00-07:00"));
第一个返回
Sun
,第二个返回
Mon
。我真的不知道为什么或如何纠正!
日期:“2013-06-16T06:00:00-07:00”
是我从XML文件中检索的数据。
时间戳
在末尾对
UTC
进行了更正,但不确定这是否产生了错误


感谢您的帮助。

这是因为日期表示时间在“设置”中指定的时区内。因此,时区
-07:00
被解析并转换回
date.timezone
时区

要理解这个想法,只需在日期字符串中添加
e

echo date('D e',strtotime("2013-06-16T06:00:00-07:00"));
echo date('D e',strtotime("2013-06-16T18:00:00-07:00"));


你最好用它。它没有这样的限制。

< P>为了得到预期的结果,你应该考虑使用:

<?php
echo date('D',strtotime("2013-06-16T06:00:00-07:00")) . "\n";
echo date('D',strtotime("2013-06-16T18:00:00-07:00")) . "\n";;

$dt1 = new DateTime("2013-06-16T06:00:00-07:00");
$dt2 = new DateTime("2013-06-16T18:00:00-07:00");
echo $dt1->format('D') . "\n";
echo $dt2->format('D') . "\n";
Sun
Mon
Sun
Sun