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: 2016-07-25 15:44 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: a3297627 at owlpic dot com Assigned: cmb (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.2.13 OS: Linux
Private report: No CVE-ID: None
 [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.
 [2016-07-25 15:44 UTC] cmb@php.net
-Status: Assigned +Status: Not a bug -Assigned To: derick +Assigned To: cmb
 [2016-07-25 15:44 UTC] cmb@php.net
Neither KST, KDT nor EDT are supported timezones[1]; therefore
this is not a bug.

[1] <http://php.net/manual/en/timezones.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC