PHP 时区 getTransitions 值得信赖吗?

发布于 2024-09-29 09:18:24 字数 889 浏览 0 评论 0原文

您是否曾经遇到过通过 getTransitions 函数进行 PHP 时区转换的任何问题?

我正在尝试将阿根廷日期转换为 GMT。如果我查看转换数组,我会得到:

....
[63] => Array ( [ts] => 1287284400 [time] => 2010-10-17T03:00:00+0000 [offset] => -7200 [isdst] => 1 [abbr] => ARST )
[64] => Array ( [ts] => 1300586400 [time] => 2011-03-20T02:00:00+0000 [offset] => -10800 [isdst] => [abbr] => ART )
...

这意味着什么,如果我没记错的话,从 2010 年 10 月 17 日到 2011 年 3 月 20 日,阿根廷日期的秒数与 GMT 等效日期相比,它将为 -7.200(2 小时)。

但实际情况是当前的偏移量是四个小时。

请问我缺少什么? 抱歉,如果看起来像家庭作业,但在写问题之前我已经搜索并尝试了很多东西。

谢谢。

编辑: 感谢您的回复。我知道 PHP 转换是硬编码在 PHP dll.s 安装中的,因此,如果任何国家/地区政府决定更改其时间政策,那么 getTransitions 就会过时,除非您升级 PHP 安装(当您拥有生产环境或使用共享环境时,这并不那么容易)托管)。

所以新问题,存在任何网络服务或动态 API 来了解特定时区的当前时间延迟(或未来延迟),例如 http://worldtimeengine.com/api/ 但也许是免费的?

Have you ever had any issue with PHP timezones conversions through the getTransitions function?

I am trying to convert an Argentinian date into GMT. If I look into the array of transitions, I get:

....
[63] => Array ( [ts] => 1287284400 [time] => 2010-10-17T03:00:00+0000 [offset] => -7200 [isdst] => 1 [abbr] => ARST )
[64] => Array ( [ts] => 1300586400 [time] => 2011-03-20T02:00:00+0000 [offset] => -10800 [isdst] => [abbr] => ART )
...

what means, If I am not wrong, from 2010-10-17 until 2011-03-20 the difference in seconds of the Argentinian date, compared with the GMT equivalent, it will be -7.200 (2 hours).

But reality is the current offset is four hours.

Please, what I am missing?
Sorry if looks like homework but I have searched and tried a lot of things before writing the question.

Thanks.

Edit:
Thank you for the responses. I understand PHP transitions are hardcoded in PHP dll.s installations, so if any country government decide to change their time policies then getTransitions became obsolete unless you upgrade your PHP installation (something not so easy when you have a production environment or are using a shared hosting).

So new question, there exists any webservices or dynamic API to know the current time delay (or future delay) for a specific timezone, like http://worldtimeengine.com/api/ but perhaps free?

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

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

发布评论

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

评论(1

郁金香雨 2024-10-06 09:18:24

我不确定这是否正确?

http://en.wikipedia.org/wiki/Time_in_Argentina

表示阿根廷通常使用 UTC - 3、他们有时遵守夏令时。哪个会使 UTC -2?

另一方面,文章指出他们目前不遵守夏令时,所以这会让他们保持在 UTC-3 (-10800)?您拥有的时间数据库可能是旧的?

I'm not sure that's incorrect?

http://en.wikipedia.org/wiki/Time_in_Argentina

States that generally Argentina is on UTC -3, and that they sometimes observe summer time. Which would make it UTC -2?

On the other hand, the article states that they don't currently observe summer time, so that would keep them at UTC-3 (-10800)? It's possible that the time database you have is old?

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