PHP 8.1 中 getTransitions 可能存在错误?

发布于 2025-01-15 05:03:28 字数 1442 浏览 0 评论 0原文

我知道许多与日期相关的错误已在 PHP 8.1 中修复,但它可能引入了新的...

以这段代码为例:

$time_zone_id = 'America/Vancouver';
$timeZone = new DateTimeZone($time_zone_id);
$trans = $timeZone->getTransitions(time(), strtotime('+1 year', time()));
print_r($trans);

PHP 7.3, 7.4 & 中8.0,它输出下一年的夏令时转换(从当前状态开始):

Array
(
    [0] => Array
        (
            [ts] => 1647637122
            [time] => 2022-03-18T20:58:42+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )

    [1] => Array
        (
            [ts] => 1667725200
            [time] => 2022-11-06T09:00:00+0000
            [offset] => -28800
            [isdst] => 
            [abbr] => PST
        )

    [2] => Array
        (
            [ts] => 1678615200
            [time] => 2023-03-12T10:00:00+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )

)

但在 PHP 8.1 中,它仅返回当前状态:

Array
(
    [0] => Array
        (
            [ts] => 1647637451
            [time] => 2022-03-18T21:04:11+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )

)

我错过了吗是什么东西或者是一个错误?

I know a lot of date-related bugs have been fixed in PHP 8.1, but it may have introduced new ones...

Take this code:

$time_zone_id = 'America/Vancouver';
$timeZone = new DateTimeZone($time_zone_id);
$trans = $timeZone->getTransitions(time(), strtotime('+1 year', time()));
print_r($trans);

In PHP 7.3, 7.4 & 8.0, it outputs the daylight savings time transitions for the next year (starting with the current state):

Array
(
    [0] => Array
        (
            [ts] => 1647637122
            [time] => 2022-03-18T20:58:42+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )

    [1] => Array
        (
            [ts] => 1667725200
            [time] => 2022-11-06T09:00:00+0000
            [offset] => -28800
            [isdst] => 
            [abbr] => PST
        )

    [2] => Array
        (
            [ts] => 1678615200
            [time] => 2023-03-12T10:00:00+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )

)

But in PHP 8.1, it returns only the current state:

Array
(
    [0] => Array
        (
            [ts] => 1647637451
            [time] => 2022-03-18T21:04:11+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )

)

Am I missing something or is it a bug?

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

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

发布评论

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

评论(1

寂寞清仓 2025-01-22 05:03:28

此问题已在 PHP 8.1.6 中得到修复。因此,该错误存在于 PHP 8.1.0 至 8.1.5 中。

This issue was fixed in PHP 8.1.6. So, the bug is present in PHP 8.1.0 thru 8.1.5.

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