php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69690 IntlDateFormatter returns null for some timezones
Submitted: 2015-05-22 08:56 UTC Modified: 2015-05-31 04:22 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: forsoap at gmail dot com Assigned:
Status: No Feedback Package: intl (PECL)
PHP Version: 5.6.9 OS: Fedora 21
Private report: No CVE-ID: None
 [2015-05-22 08:56 UTC] forsoap at gmail dot com
Description:
------------
For some timezones IntlDateFormatter returns null instead of instance.

Test script:
---------------
foreach (\DateTimeZone::listIdentifiers() as $timezone) {
    $formatter = new \IntlDateFormatter(
        'en_US',
        1,
        1,
        $timezone,
        null,
        null
    );
    if (null === $formatter) {
        echo $timezone . PHP_EOL;
    }
}

Expected result:
----------------
Output is empty

Actual result:
--------------
Antarctica/Troll
Asia/Chita
Asia/Srednekolymsk
Pacific/Bougainville

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-22 14:28 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2015-05-22 14:28 UTC] danack@php.net
Hi,

The issue of the IntlDateFormatter returning null will be fixed with the release of PHP 7; the behaviour was deliberate before, but was changed by an RFC https://wiki.php.net/rfc/internal_constructor_behaviour

Just to note, your code example below will now throw an IntlException where it was before returning null from the constructor. The root cause of it failing to make the IntlDateFormatter is, I presume, that the Intl library is not aware of those timezones, as that library gets its data from a different location than the DateTime library.

If you think PHP should be aware of those timezones, please can you check that the ICU library on your system is aware for them?

cheers
Dan
 [2015-05-31 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC