[php-src] Issue #8173: Intl MessageFormatter using incorrect timezone
| From: | skrpc | Date: | Fri, 04 Mar 2022 20:39:27 +0000 |
| Subject: | [php-src] Issue #8173: Intl MessageFormatter using incorrect timezone | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240218@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8173
Author: skrpc
### Description
The following code:
```
<?php
\Locale::setDefault('en-CA');
date_default_timezone_set('America/Edmonton');
$now = new \DateTime();
echo "DateFormatter - [" . \IntlDateFormatter::formatObject($now,
[\IntlDateFormatter::FULL, \IntlDateFormatter::FULL]) . "]\n";
echo "Singular - [" . \MessageFormatter::formatMessage(
\Locale::getDefault(),
'{0, date, full} - {0, time, full}',
[$now]
) . "]\n";
echo "Plural - [" . \MessageFormatter::formatMessage(
\Locale::getDefault(),
'{0, plural,
=0 {{1, date, full} - {1, time, full}.}
other {{1, date, full} - {1, time, full}.}
}',
[1, $now]
) . "]\n";
?>
```
Resulted in this output:
DateFormatter - [Friday, March 4, 2022 at 1:28:49 p.m. Mountain Standard Time]
Singular - [Friday, March 4, 2022 - 1:28:49 p.m. Mountain Standard Time]
Plural - [Friday, March 4, 2022 - 8:28:49 p.m. Coordinated Universal Time.]
But I expected this output instead:
Plural to be the same as Singular (i.e. seems to be ignoring the default timezone and defaulting to
server timezone of UTC
### PHP Version
PHP 8.1.3
### Operating System
Ubuntu 18.04.6 LTS