-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateTimeZone::listIdentifiers returns a timezone Etc/GMT+0 which can not be used by DateTimeZone constructor #10287
Comments
This is a duplicate of #10218 |
Thnx @heiglandreas for quick answer. This works fine: <?php
$timezoneIdentifiers = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC);
foreach($timezoneIdentifiers as $timezoneIdentifier) {
if (in_array($timezoneIdentifier, [
'Etc/GMT+0',
'Etc/GMT+1',
'Etc/GMT+2',
'Etc/GMT+3',
'Etc/GMT+4',
'Etc/GMT+5',
'Etc/GMT+6',
'Etc/GMT+7',
'Etc/GMT+8',
'Etc/GMT+9',
'Etc/GMT+10',
'Etc/GMT+11',
'Etc/GMT+12'
])) continue;
(new \DateTimeZone($timezoneIdentifier));
} We will avoid using this timezones: https://www.php.net/manual/en/timezones.others.php and since it is duplicate I am closing this issue. It would be nice those won't be returned with listIdentifiers though. |
Well... When you are requesting ALL identifiers, also the ones for BackwardsCompatibility, then you should not wonder, that ALL identifiers including the ones for backwards compatibility are returned... You should by now only use the identifiers that are returned by |
This seems to be fixed: #10297 (comment) |
@heiglandreas Then what's the point of |
Description
The following code:
Resulted in this output:
But I expect if DateTimeZone::getIdentifiers retuns a timezone it is also possible to use it in constructor.
It is working fine in PHP 8.2.0.
PHP Version
PHP 8.2.1
Operating System
php:8.2-fpm-alpine
The text was updated successfully, but these errors were encountered: