'Possible bug with getTransitions in PHP 8.1?

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Goozak