|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-13 12:08 UTC] jani@php.net
[2008-03-13 18:53 UTC] tessone at polyglut dot net
[2008-03-14 12:11 UTC] jani@php.net
[2008-03-17 03:27 UTC] tessone at polyglut dot net
[2008-03-17 20:51 UTC] jani@php.net
[2008-03-19 01:42 UTC] tessone at polyglut dot net
[2008-03-21 00:30 UTC] jani@php.net
[2008-03-28 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 20:00:01 2025 UTC |
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