php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45081 strtotime incorrectly interprets SGT time zone
Submitted: 2008-05-23 15:39 UTC Modified: 2013-06-12 19:56 UTC
Votes:7
Avg. Score:4.4 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:6 (85.7%)
Same OS:4 (57.1%)
From: george dot wright at infimatic dot com Assigned: derick
Status: Assigned Package: Date/time related
PHP Version: 5.2.6 OS: SUSE 10.2
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-05-23 15:39 UTC] george dot wright at infimatic dot com
Description:
------------
Our server is set up for Asia/Singapore time

OS date command prints:   Fri May 23 22:29:19 SGT 2008

Running the following code should produce the same result since the default timezone is SGT but it doesn't. Updating the timezonedb.so file to version 2008.2 (the newest available version) did not fix the problem.

Reproduce code:
---------------
<?php

print strtotime('2008-05-23 00:00:00 SGT');
print "<br>";
print strtotime('2008-05-23 00:00:00');

?>

Expected result:
----------------
1211473800
1211473800


Actual result:
--------------
1211473800
1211472000

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-23 16:42 UTC] derick@php.net
There is an issue here, but the expected result is:
1211472000
1211472000
 [2008-05-23 17:43 UTC] george dot wright at infimatic dot com
Correct, my copy/paste mistake. Ant ETA on a fix?
 [2013-05-30 00:43 UTC] sdf at fake-email-address dot com
Any update on this?

I'm using PHP 5.3.3-7+squeeze15 with timezonedb 2013.3 and SGT is still off by 30 
minutes.
 [2013-05-30 08:38 UTC] php at synotna dot org
Probable workaround? http://pecl.php.net/package/timezonedb
 [2013-05-30 23:44 UTC] sdf at fake-email-address dot com
Unfortunately not. The offsets are hard coded into PHP, timezonedb is not used for 
strtotime.
 [2013-05-31 13:46 UTC] derick@php.net
Timezonedb is used for strtotime.
 [2013-06-10 06:57 UTC] sdf at fake-email-address dot com
If only it were..

ext/date/lib/parse_date.c:

/* The timezone table. */
const static timelib_tz_lookup_table timelib_timezone_lookup[] = {
#include "timezonemap.h"
	{ NULL, 0, 0, NULL },
};

ext/date/lib/timezonemap.h:

	{ "acst",  1, -14400, "America/Porto_Acre"            },
	{ "acst",  1, -14400, "America/Eirunepe"              },
	{ "acst",  1, -14400, "America/Rio_Branco"            },
	{ "acst",  1, -14400, "Brazil/Acre"                   },
	{ "act",   0, -18000, "America/Porto_Acre"            },

etc. All hard coded.
 [2013-06-12 19:56 UTC] aharvey@php.net
That file is autogenerated from timezonedb, I believe.
 [2013-07-19 08:45 UTC] sdf at fake-email-address dot com
I don't see any evidence of this file being autogenerated. It's included in the 
source distribution. Maybe it's autogenerated at some point by someone, but the 
timezonedb.h that gets included in the build is essentially hard-coded and doesn't 
use the system timezonedb at any point.

If it is autogenerated, maybe it's time for someone to rebuild it and update the 
distribution.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 21:01:55 2014 UTC