php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51557 timelib_timezone_lookup has invalid DST entries, breaks strtotime
Submitted: 2010-04-15 06:17 UTC Modified: 2010-04-30 00:55 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: a3297627 at owlpic dot com Assigned: derick
Status: Assigned Package: Date/time related
PHP Version: 5.2.13 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-04-15 06:17 UTC] a3297627 at owlpic dot com
Description:
------------
It seems timezonemap.h was generated by a tzdata parser that unfortunately did not include information on the years Daylight Saving Time was in use. In particular, in South Korea, there is no DST, yet there exists KST/KDT distinction in strtotime that thinks KDT is currently active, with inconsistencies with other date/time functions.

Test script:
---------------
<?php
function tzconvert ($input, $timezone)
{
        $ts = strtotime ($input);
        $time = gmdate ('r', $ts);
        $dt = new DateTime ($time);
        $dt->setTimeZone (new DateTimeZone ($timezone));
        echo "Input: $time\nConverted: " . $dt->format ('l, M d g:ia T') . "\n";
}

tzconvert ("Thursday, April 15 2010 12:00am EDT", "KST");
tzconvert ("Thursday, April 15 2010 12:00am EDT", "KDT");

tzconvert ("Thursday, Apr 15 1:00pm KST", "EDT");
tzconvert ("Thursday, Apr 15 1:00pm KDT", "EDT");
?>


Expected result:
----------------
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 05:00:00 +0000
Converted: Thursday, Apr 15 1:00am EDT
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 12:00am EDT


Actual result:
--------------
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 05:00:00 +0000
Converted: Thursday, Apr 15 1:00am EDT
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00am EDT


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-15 06:19 UTC] a3297627 at owlpic dot com
Copy/paste error, the test output should read:

Expected result:

Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 05:00:00 +0000
Converted: Thursday, Apr 15 12:00am EDT
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 12:00am EDT

Actual Result:
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 1:00pm KST
Input: Thu, 15 Apr 2010 05:00:00 +0000
Converted: Thursday, Apr 15 1:00am EDT
Input: Thu, 15 Apr 2010 04:00:00 +0000
Converted: Thursday, Apr 15 12:00am EDT
 [2010-04-30 00:55 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2012-05-24 01:34 UTC] kavi at postpro dot net
Is this actually a dupe of https://bugs.php.net/bug.php?id=62130  ???

Anyway, I updated the test a bit for 2012 (the original didn't include the year 
in the second pair of tzconvert calls) and put the date in June to very clearly 
avoid DST boundaries.


<?
function tzconvert ($input, $timezone)
{
        $ts = strtotime ($input);
        $time = gmdate ('r', $ts);
        $dt = new DateTime ($time);
        $dt->setTimeZone (new DateTimeZone ($timezone));
        echo "Input: $time\nConverted: " . $dt->format ('l, M d g:ia T') . "\n";
}

tzconvert("Tuesday, June 15 2010 12:00am EDT", "KST");
tzconvert("Tuesday, June 15 2010 12:00am EDT", "KDT");
tzconvert("Tuesday, June 15 2010 1:00pm KST", "EDT");
tzconvert("Tuesday, June 15 2010 1:00pm KDT", "EDT");

<?
function tzconvert ($input, $timezone)
{
        $ts = strtotime ($input);
        $time = gmdate ('r', $ts);
        $dt = new DateTime ($time);
        $dt->setTimeZone (new DateTimeZone ($timezone));
        echo "Input: $time\nConverted: " . $dt->format ('l, M d g:ia T') . "\n";
}

tzconvert("Tuesday, June 15 2010 12:00am EDT", "KST");
tzconvert("Tuesday, June 15 2010 12:00am EDT", "KDT");
tzconvert("Tuesday, June 15 2010 1:00pm KST", "EDT");
tzconvert("Tuesday, June 15 2010 1:00pm KDT", "EDT");


Input: Tue, 15 Jun 2010 04:00:00 +0000
Converted: Tuesday, Jun 15 1:00pm KST
Input: Tue, 15 Jun 2010 04:00:00 +0000
Converted: Tuesday, Jun 15 1:00pm KST
Input: Tue, 15 Jun 2010 05:00:00 +0000
Converted: Tuesday, Jun 15 1:00am EDT
Input: Tue, 15 Jun 2010 04:00:00 +0000
Converted: Tuesday, Jun 15 12:00am EDT


The actual problem really seems like bug #62130, but with an argument provided 
to the DateTime constructor as a DateTimeZone, not in the time string itself.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 09:02:23 2014 UTC