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:8
Avg. Score:4.5 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:7 (87.5%)
Same OS:5 (62.5%)
From: george dot wright at infimatic dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.6 OS: SUSE 10.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: george dot wright at infimatic dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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.
 [2015-01-19 22:59 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b0159431e3363f6b15561c7dfa0cdb247c287223
Log: Fixed bug #45081 (strtotime incorrectly interprets SGT time zone).
 [2015-01-19 22:59 UTC] derick@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC