gpt4 book ai didi

php - UTC 是否遵守夏令时?

转载 作者:IT老高 更新时间:2023-10-28 11:55:53 25 4
gpt4 key购买 nike

我正在尝试编写一个脚本,我想将任何时区转换为 UTC 并反转。但是从一些地方我了解到,在考虑或不考虑 DST 的情况下将任何时区转换为 UTC 时,它会给出相同的 UTC 时间。例如:如果我尝试转换这个:

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

到 UTC 与 DST 和没有 DST,我会得到 ..

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

这是正确的吗??如果是,那为什么???请任何人给我你的答案。

最佳答案

不,UTC 本身从来没有 DST。它是其他时区相对于表示的恒定引用系。

来自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.

换句话说,当一个时区遵守 DST 时,它与 UTC 的偏移会在 DST 转换时发生变化,但那个时区遵守 DST,而不是 UTC。

在不太了解 PHP 时区处理的情况下,您可以在转换中指定“带 DST”或“不带 DST”对我来说似乎很奇怪 - 时区本身指定 DST 何时开始......它不应该必须是您自己指定的内容。

关于php - UTC 是否遵守夏令时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5495803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com