|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66323 IntlDateFormatter returns null when DateTimeZone value provided.
Submitted: 2013-12-19 08:07 UTC Modified: 2013-12-19 21:22 UTC
From: pavvka at gmail dot com Assigned:
Status: Not a bug Package: intl (PECL)
PHP Version: 5.5.7 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: pavvka at gmail dot com
New email:
PHP Version: OS:


 [2013-12-19 08:07 UTC] pavvka at gmail dot com
When creating instance of IntlDateFormatter and DateTimeZone value is provided, object is not created and null value is returned instead.

If 4th parameter (\DateTimeZone::UTC) is not provided, IntlDateFormatter object is created.

Test script:
$f1 = new \IntlDateFormatter(\Locale::getDefault(), 1, \IntlDateFormatter::NONE);

$f2 = new \IntlDateFormatter(\Locale::getDefault(), 1, \IntlDateFormatter::NONE, \DateTimeZone::UTC);

$f3 = new \IntlDateFormatter(\Locale::getDefault(), 1, \IntlDateFormatter::NONE, \DateTimeZone::EUROPE);

Expected result:
class IntlDateFormatter#1 (0) {
class IntlDateFormatter#2 (0) {
class IntlDateFormatter#3 (0) {

Actual result:
class IntlDateFormatter#1 (0) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-19 17:35 UTC]
-Package: Date/time related +Package: intl
 [2013-12-19 21:22 UTC]
-Status: Open +Status: Not a bug
 [2013-12-19 21:22 UTC]
The fourth argument of IntlDateFormatter's constructor can either be a valid timezone identifier from the ICU database or an instance of IntlTimeZone or DateTimeZone. The constants in your example are just integers, which will not work.

What's odd is that the constructor is returning NULL. According to the documentation it should return FALSE. I'll look into that.
 [2014-07-31 11:53 UTC] fpruis at e-sites dot nl
A constructor should never return either false or null, but throw an exception when construction fails. 

Either way, this seems like broken backward compatibility. Passing an integer (from DateTimeZone::UTC) used to work with v3.6, but now we upgraded to v4.8.1.1 it is broken.

We will be upgrading Symfony (v2.0.4) to resolve the issue for us, but I do recommend having the constructor throw an exception instead of returning null.
 [2016-05-04 10:52 UTC] heah at heahprod dot com
Hi, what's the status of this issue?
 [2017-05-31 15:44 UTC] imprec at gmail dot com
Reproduced the issue, it's related to the datetimezone name parsing.

For instance, this fails:

new \IntlDateFormatter(\Locale::getDefault(), 1, \IntlDateFormatter::NONE, 'utc');

Whereas this succeeds:

new \IntlDateFormatter(\Locale::getDefault(), 1, \IntlDateFormatter::NONE, 'UTC');
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 07:01:31 2024 UTC