php 的 date_default_timezone_set 是否会调整为夏令时?

发布于 2024-12-07 21:53:03 字数 194 浏览 6 评论 0原文

php的date_default_timezone_set是否调整为夏令时?

我有这段代码,想知道它是否总是会产生正确的斯德哥尔摩时间?

  date_default_timezone_set('Europe/Stockholm');
  $timestamp = date("Y-m-d H:i:s");

Does php's date_default_timezone_set adjust to daylight saving?

I have this code, and wonder if it will always result in the correct Stockholm time?

  date_default_timezone_set('Europe/Stockholm');
  $timestamp = date("Y-m-d H:i:s");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼泪也成诗 2024-12-14 21:53:03

PHP 不会自动处理 DST。你必须检查

if (date('I', time()) == 1) ... the time is in DST mode ("0" = not)

然后你应该相应地调整时间。
(注:“I”大写。我刚刚检查过,它有效。)

PHP doesn't handle DST automatically. You have to check

if (date('I', time()) == 1) ... the time is in DST mode ("0" = not)

Then you should adust time accordingly.
(Note: 'I' in capital. I have just checked it and it works.)

北笙凉宸 2024-12-14 21:53:03

是的,这应该总是在正确的时间产生。

Yes this should always result in the right time.

冬天旳寂寞 2024-12-14 21:53:03

只要您的时区在以下链接中列出,时间戳就应该相对于正确的时区。

http://www.php.net/manual/en/timezones.php

As long as your timezone is listed in the following link, timestamp should be relative to the correct timezone.

http://www.php.net/manual/en/timezones.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文