|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-05 14:28 UTC] duerra_NOT_THIS_ at pushitlive dot net
Description:
------------
When using Etc/GMT related values with date_default_timezone_set(), the values are backwards of what they should be.
Reproduce code:
---------------
<?php
date_default_timezone_set('Etc/GMT');
echo date('H:i').'<br />';
date_default_timezone_set('Etc/GMT-1');
echo date('H:i');
?>
Expected result:
----------------
14:27
13:27
Actual result:
--------------
14:27
15:27
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 22:00:02 2025 UTC |
Your OS does the same for example: derick@kossu:~$ TZ=UTC date Thu Oct 5 16:26:02 UTC 2006 derick@kossu:~$ TZ=GMT-2 date Thu Oct 5 18:26:07 GMT 2006 derick@kossu:~$ TZ=GMT+6 date Thu Oct 5 10:26:11 GMT 2006 The explanation (from the timezone database definition files) why it is like this: # We use POSIX-style signs in the Zone names and the output abbreviations, # even though this is the opposite of what many people expect. # POSIX has positive signs west of Greenwich, but many people expect # positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses # the abbreviation "GMT+4" and corresponds to 4 hours behind UTC # (i.e. west of Greenwich) even though many people would expect it to # mean 4 hours ahead of UTC (i.e. east of Greenwich). The timezones you can specify in PHP come directly from this database, just like it would have been before (in PHP 4 and 5.0). They also do not take care of daylight savingstime either so they're definitely not useful and concise. Nothing in PHP is deprecated either as before you'd do this with the putenv("TZ=xxx") env var which would have given you the exact same result. Definitely a bogus bug.