From: tessone at polyglut dot net
Operating system: CentOS
PHP version: 5.2.5
PHP Bug Type: Date/time related
Bug description: localtime sometimes gives GMT date, not local
Description:
------------
When using localtime() to get the server time into an array, sometimes PHP
chooses the local timezone, sometimes it chooses GMT. I am in US/Eastern
(-0500), so after 7pm, sometimes my script says it's today, sometimes
tomorrow (because it is choosing GMT).
Below is some code, plus a result from when it chooses the local timezone
(correct) and one where it chooses GMT (incorrect).
If I run date at the command-line, it consistently returns a US/Eastern
time, so the server is not skipping back and forth between timezones for
any reason.
Reproduce code:
---------------
print time() . ": ";
$serverTime = localtime(time());
print_r($serverTime);
print date("O");
Expected result:
----------------
1205022657: Array ( [0] => 57 [1] => 30 [2] => 19 [3] => 8 [4] => 2 [5] =>
108 [6] => 6 [7] => 67 [8] => 0 ) -0500
Actual result:
--------------
1205022665: Array ( [0] => 5 [1] => 31 [2] => 0 [3] => 9 [4] => 2 [5] =>
108 [6] => 0 [7] => 68 [8] => 0 ) +0000
--
Edit bug report at http://bugs.php.net/?id=44380&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44380&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44380&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44380&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44380&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44380&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44380&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44380&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44380&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44380&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44380&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44380&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44380&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44380&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44380&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44380&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44380&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44380&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44380&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44380&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44380&r=mysqlcfg