[php-src] Issue #8771: IntlDateFormatter Date error due to time zone conversion
| From: | f2h2h1 | Date: | Tue, 14 Jun 2022 05:09:37 +0000 |
| Subject: | [php-src] Issue #8771: IntlDateFormatter Date error due to time zone conversion | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241723@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8771
Author: f2h2h1
### Description
The following code:
```php
<?php
$date = new \DateTime('2021-12-28 17:35:20');
$pattern = 'YYYY-MM-dd HH:mm:ss';
$locale = 'en_US';
$timezone = new \DateTimeZone('utc');
$formatter = new
\IntlDateFormatter($locale,\IntlDateFormatter::SHORT,\IntlDateFormatter::SHORT,$timezone);
$timezone = 'Asia/Hong_Kong';
$formatter->setTimeZone($timezone);
$formatter->setPattern($pattern);
var_dump($formatter->format($date));
```
Resulted in this output:
```
string(19) "2022-12-29 01:35:20"
```
But I expected this output instead:
```
string(19) "2021-12-29 01:35:20"
```
### PHP Version
php 7.4.26
### Operating System
Windows 10 21H2