协调世界时是否观察夏时制?

我试图写一个脚本,我想转换任何时区的 UTC和反向。 但是从一些地方我来知道,当转换任何时区到 UTC与或没有 DST 的考虑,它将给予相同的 UTC时间。 例如: 如果我试图转换这个:

$mytime = '2011-03-31 05:06:00.000';
$myzone = 'America/New_York';

到协调世界时,没有 DST,我会得到. 。

(New_York->UTC DST=Yes)2011-03-31 09:06:00
(New_York->UTC DST=No)2011-03-31 09:06:00 ..........

这是正确的吗? ? 如果是,那么为什么? ? ? 谁能告诉我你们的答案。

97517 次浏览

No, UTC itself never has DST. It is the constant frame of reference other time zones are expressed relative to.

From the Wikipedia UTC page:

UTC does not change with a change of seasons, but local time or civil time may change if a time zone jurisdiction observes daylight saving time or summer time. For example, UTC is 5 hours ahead of local time on the east coast of the United States during winter, but 4 hours ahead during summer.

In other words, when a time zone observes DST, its offset from UTC changes when there's a DST transition, but that's that time zone observing DST, not UTC.

Without knowing much about PHP time zone handling, it seems strange to me that you can specify "with DST" or "without DST" in a conversion - the time zones themselves specify when DST kicks in... it shouldn't have to be something you specify yourself.

I'm having the same issue, using this code:

date_default_timezone_set('UTC');
$nowdate = date('l jS \of F Y h:i:s A');
echo "Current date and time is: " . $nowdate;

It is summer now, and the time this code produces is one hour behind - so I don't think that UTC time in PHP adjusts to DST.

Be interesting to see if anyone has the solution...

EDIT:

Found this code on a forum, works perfectly!!

date_default_timezone_set('Europe/London');
$TIME =  date("m/d/Y H:i",time());

So you can then call the current date and time by using $TIME. The output can be adjusted to display it differently by changing the bit inside the date() tag. If you want to adjust the date() output, use this guide: http://php.net/manual/en/function.time.php

Hope this helps :)