[php-src] Issue #10218: DateTimeZone fails to parse time zones that contain the "+" character

From: Date: Wed, 04 Jan 2023 14:05:05 +0000
Subject: [php-src] Issue #10218: DateTimeZone fails to parse time zones that contain the "+" character
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243332@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10218
Author: spideyfusion

### Description

The following code:

```php
<?php
var_dump(new DateTime('now', new DateTimeZone('Etc/GMT+1')));
```

Resulted in this output:
```
Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/GMT+1) in
/in/bGhje:3
Stack trace:
#0 /in/bGhje(3): DateTimeZone->__construct('Etc/GMT+1')
#1 {main}
  thrown in /in/bGhje on line 3
```

But I expected this output instead:
```
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2023-01-04 12:37:42.004396"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(9) "Etc/GMT+1"
}
```

---

3v4l.org link: https://3v4l.org/bGhje#v8.2.1

---

Looks like it broke after the latest timelib update. Looking through the recent
changes, it seems that the + character is not considered in
[this](https://github.com/derickr/timelib/blob/e7ffbb24750a12dd39dc7de9e3e5acba9f586511/parse_date.re#L784)
lookup function.

@derickr Could you take a look at this?

### PHP Version

PHP 8.2.1 RC1

### Operating System

_No response_


Thread (1 message)

  • spideyfusion
« previous php.bugs (#243332) next »