PHP 8.1 中 getTransitions 可能存在错误?
我知道许多与日期相关的错误已在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题已在 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.