php.net |  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
Votes:1
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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shumisha at gmail dot com
New email:
PHP Version: OS:

 

 [2010-05-14 10:10 UTC] shumisha at gmail dot com
Description:
------------
Hi

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:
Australia/ACT
NZ-CHAT
America/Know_IN
Australia/LHI
Chile/EasterIsland
Europe/Isle_of_Man

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-15 18:48 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-07-18 01:20 UTC] k.schroeder@php.net
Automatic comment from SVN on behalf of k.schroeder
Revision: http://svn.php.net/viewvc/?view=revision&revision=301360
Log: Test for #51819
 [2011-06-05 15:30 UTC] bjori@php.net
Automatic comment from SVN on behalf of bjori
Revision: http://svn.php.net/viewvc/?view=revision&revision=311831
Log: Fixed bug#51819 (Case discrepancy in timezone names cause Uncaught exception and fatal error)
 [2011-06-05 15:30 UTC] bjori@php.net
-Status: Assigned +Status: Closed -Assigned To: derick +Assigned To: bjori
 [2011-06-05 15:30 UTC] bjori@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.3 & 5.4
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC