PHP 8.1 中的 getTransitions 可能存在错误?
Possible bug with getTransitions in PHP 8.1?
我知道有很多与日期相关的错误 fixed in 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
)
)
但是在PHP8.1中,它returns只有当前状态:
Array
(
[0] => Array
(
[ts] => 1647637451
[time] => 2022-03-18T21:04:11+0000
[offset] => -25200
[isdst] => 1
[abbr] => PDT
)
)
我是不是遗漏了什么或者是错误?
此问题已在 PHP 8.1.6 中修复。因此,该错误存在于 PHP 8.1.0 至 8.1.5 中。
我知道有很多与日期相关的错误 fixed in 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
)
)
但是在PHP8.1中,它returns只有当前状态:
Array
(
[0] => Array
(
[ts] => 1647637451
[time] => 2022-03-18T21:04:11+0000
[offset] => -25200
[isdst] => 1
[abbr] => PDT
)
)
我是不是遗漏了什么或者是错误?
此问题已在 PHP 8.1.6 中修复。因此,该错误存在于 PHP 8.1.0 至 8.1.5 中。