Skip to content
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

new DateTimeZone('Etc/GMT+9') fails with fatal error since 8.1.14 #10286

Closed
nicolas-grekas opened this issue Jan 11, 2023 · 1 comment
Closed

Comments

@nicolas-grekas
Copy link
Contributor

Description

The following code (see https://3v4l.org/lfalF):

var_dump(date_default_timezone_set('Etc/GMT+9'));

$d = new DateTime();

var_dump($d->getTimeZone());

new DateTimeZone('Etc/GMT+9');

Resulted in this output:

Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/GMT+9)

But I expected this output instead:

no error

As highlighted by the code sample, it's possible to create such a DateTimeZone object via DateTime::getTimeZone.

PHP Version

PHP 8.1.14+

Operating System

No response

@derickr
Copy link
Member

derickr commented Jan 11, 2023

Duplicate of #10218, which I fixed yesterday.

Please do note that using these Etc/GMT+7 style time zones should be avoid, as the +7 really means UTC-7, and they're also listed on the "avoid these please" in the manual: https://www.php.net/manual/en/timezones.others.php — you should make sure that users also can't easily select these.

@derickr derickr closed this as completed Jan 11, 2023
@cmb69 cmb69 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants