### Description PHP 8.1 Timezone doesn't work as intended. `offset` is wrong in PHP 8.1. ### Resulted in this output: PHP 8.0 ```php $timezone = 'Europe/Paris'; $timestamp = (new \DateTime('2022-02-16 00:00:00'))->getTimestamp(); $result = (new \DateTimeZone($timezone))->getTransitions($timestamp, $timestamp); // $result['offset'] = 3600 ``` PHP 8.1 ```php $timezone = 'Europe/Paris'; $timestamp = (new \DateTime('2022-02-16 00:00:00'))->getTimestamp(); $result = (new \DateTimeZone($timezone))->getTransitions($timestamp, $timestamp); // $result['offset'] = 7200 ``` ### But I expected this output instead: PHP 8.0 ```php $timezone = 'Europe/Paris'; $timestamp = (new \DateTime('2022-02-16 00:00:00'))->getTimestamp(); $result = (new \DateTimeZone($timezone))->getTransitions($timestamp, $timestamp); // $result['offset'] = 3600 ``` PHP 8.1 ```php $timezone = 'Europe/Paris'; $timestamp = (new \DateTime('2022-02-16 00:00:00'))->getTimestamp(); $result = (new \DateTimeZone($timezone))->getTransitions($timestamp, $timestamp); // $result['offset'] = 3600 ``` ### PHP Version 8.1 ### Operating System Ubuntu 20.04.3 LTS
Activity
[-]PHP 8 Timezone doesn't work as intended[/-][+]PHP 8 1 Timezone doesn't work as intended[/+][-]PHP 8 1 Timezone doesn't work as intended[/-][+]PHP 8.1 Timezone doesn't work as intended[/+]heiglandreas commentedon Feb 17, 2022
If you want the offset for a specific point in time I'd recommend using
DateTimeImmutable::getOffset()instead.https://3v4l.org/LXVYV
Much more concerning is to me, that PHP8.1 does not seem to return an array of Transitions at all any more.
Code:
expected Outcome: an array with three transitions
actual Output in PHP8.1: An array with one entry.
See https://3v4l.org/FSAmO
iluuu1994 commentedon Feb 17, 2022
Related to #7752.