|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51819 Case discrepancy in timezone names cause Uncaught exception and fatal error
Submitted: 2010-05-14 10:10 UTC Modified: 2011-06-05 15:30 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: shumisha at gmail dot com Assigned: bjori (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.13 OS: linux/windows
Private report: No CVE-ID: None
 [2010-05-14 10:10 UTC] shumisha at gmail dot com

There seem to be a discrepency for timezones names as reported by timezone_abbreviations_list() and the DateTime object parser. We have found a (small) numbre of timezones for which this happens:

Been reported and reproduced with PHP 5.1.41 adn PHP 5.2.13

Test script:
1 - Get identifiers list:

$all = timezone_abbreviations_list();

The resulting array contains, for instance:

[54] => Array
    [dst] => 
    [offset] => 36000
    [timezone_id] => Australia/NSW
2 - Use this timezone_id to create a DateTimeObject

$dateString = "2010-05-15 00:00:00 Australia/NSW";
$date = new DateTime( $dateString);

Expected result:
A DateTime object created

The above code runs without problem if timezone identifier (Australia/NSW) is replaced by Australia/Nsw.

I have found the following timezones to have the same issue:

In others, all timezones names that do not follow camelcase strictly. There are probably others.

Actual result:
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [datetime.--construct]: Failed to parse time string (2010-05-15 00:00:00 Australia/NSW) at position 20 (A): The timezone could not be found in the database' in /XXXX/test.php on line 4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-15 18:48 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-07-18 01:20 UTC]
Automatic comment from SVN on behalf of k.schroeder
Log: Test for #51819
 [2011-06-05 15:30 UTC]
Automatic comment from SVN on behalf of bjori
Log: Fixed bug#51819 (Case discrepancy in timezone names cause Uncaught exception and fatal error)
 [2011-06-05 15:30 UTC]
-Status: Assigned +Status: Closed -Assigned To: derick +Assigned To: bjori
 [2011-06-05 15:30 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Fixed in 5.3 & 5.4
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Sep 21 23:01:24 2023 UTC