Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Bug #14389 Timezone Offsets Wrong
Submitted: 2008-07-22 19:35 UTC
From: gopheryarrowzoo Assigned:
Status: Open Package: Date (version CVS)
PHP Version: 5.1.6 OS: CentOS
Roadmaps: (Not assigned)    
Subscription  


 [2008-07-22 19:35 UTC] gopheryarrowzoo (Gordon Grant)
Description: ------------ All Timezones with Etc/GMT give the wrong expected result the time related fields like offset and 'name' fields. noticed bug when trying to convert TimeZones from where my server is to 'localtime' anywhere in the world, trying with 'Etc/GMT' then the hours test script just shows quick example. Test script: --------------- include 'date/Timezone.php'; $tz_gmtminus12=&new Timezone('Etc/GMT-12'); print_r($tz); Expected result: ---------------- Date_TimeZone Object ( [id] => Etc/GMT-12 [longname] => GMT-12:00 [shortname] => GMT-12:00 [hasdst] => [dstlongname] => GMT-12:00 [dstshortname] => GMT-12:00 [offset] => -43200000 [default] => ) Actual result: -------------- Date_TimeZone Object ( [id] => Etc/GMT-12 [longname] => GMT+12:00 [shortname] => GMT+12:00 [hasdst] => [dstlongname] => GMT+12:00 [dstshortname] => GMT+12:00 [offset] => 43200000 [default] => )

Comments

 [2008-07-26 13:22 UTC] doconnor (Daniel O'Connor)
Uh, the test script provided isn't executable in its current form.
 [2008-07-26 15:09 UTC] gopheryarrowzoo (Gordon Grant)
add "php" tags around it like thus. <?php include 'date.php'; $tz=&new Date_TimeZone('Etc/GMT-12'); print_r($tz); ?>
 [2009-05-18 21:42 UTC] jkaehler (Jochen Kähler)
This also a Problem in 1.5.0 alpha. As a workaround you could add this in some kind of config.php or main.php which is always included first: ----------- require_once("Date/TimeZone.php"); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+1'] = array( 'offset' => 3600000, 'shortname' => 'GMT+1', 'dstshortname' => null, 'longname' => 'GMT+01:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+10'] = array( 'offset' => 36000000, 'shortname' => 'GMT+10', 'dstshortname' => null, 'longname' => 'GMT+10:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+11'] = array( 'offset' => 39600000, 'shortname' => 'GMT+11', 'dstshortname' => null, 'longname' => 'GMT+11:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+12'] = array( 'offset' => 43200000, 'shortname' => 'GMT+12', 'dstshortname' => null, 'longname' => 'GMT+12:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+2'] = array( 'offset' => 7200000, 'shortname' => 'GMT+2', 'dstshortname' => null, 'longname' => 'GMT+02:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+3'] = array( 'offset' => 10800000, 'shortname' => 'GMT+3', 'dstshortname' => null, 'longname' => 'GMT+03:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+4'] = array( 'offset' => 14400000, 'shortname' => 'GMT+4', 'dstshortname' => null, 'longname' => 'GMT+04:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+5'] = array( 'offset' => 18000000, 'shortname' => 'GMT+5', 'dstshortname' => null, 'longname' => 'GMT+05:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+6'] = array( 'offset' => 21600000, 'shortname' => 'GMT+6', 'dstshortname' => null, 'longname' => 'GMT+06:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+7'] = array( 'offset' => 25200000, 'shortname' => 'GMT+7', 'dstshortname' => null, 'longname' => 'GMT+07:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+8'] = array( 'offset' => 28800000, 'shortname' => 'GMT+8', 'dstshortname' => null, 'longname' => 'GMT+08:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT+9'] = array( 'offset' => 32400000, 'shortname' => 'GMT+9', 'dstshortname' => null, 'longname' => 'GMT+09:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-1'] = array( 'offset' => -3600000, 'shortname' => 'GMT-1', 'dstshortname' => null, 'longname' => 'GMT-01:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-10'] = array( 'offset' => -36000000, 'shortname' => 'GMT-10', 'dstshortname' => null, 'longname' => 'GMT-10:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-11'] = array( 'offset' => -39600000, 'shortname' => 'GMT-11', 'dstshortname' => null, 'longname' => 'GMT-11:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-12'] = array( 'offset' => -43200000, 'shortname' => 'GMT-12', 'dstshortname' => null, 'longname' => 'GMT-12:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-13'] = array( 'offset' => -46800000, 'shortname' => 'GMT-13', 'dstshortname' => null, 'longname' => 'GMT-13:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-14'] = array( 'offset' => -50400000, 'shortname' => 'GMT-14', 'dstshortname' => null, 'longname' => 'GMT-14:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-2'] = array( 'offset' => -7200000, 'shortname' => 'GMT-2', 'dstshortname' => null, 'longname' => 'GMT-02:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-3'] = array( 'offset' => -10800000, 'shortname' => 'GMT-3', 'dstshortname' => null, 'longname' => 'GMT-03:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-4'] = array( 'offset' => -14400000, 'shortname' => 'GMT-4', 'dstshortname' => null, 'longname' => 'GMT-04:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-5'] = array( 'offset' => -18000000, 'shortname' => 'GMT-5', 'dstshortname' => null, 'longname' => 'GMT-05:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-6'] = array( 'offset' => -21600000, 'shortname' => 'GMT-6', 'dstshortname' => null, 'longname' => 'GMT-06:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-7'] = array( 'offset' => -25200000, 'shortname' => 'GMT-7', 'dstshortname' => null, 'longname' => 'GMT-07:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-8'] = array( 'offset' => -28800000, 'shortname' => 'GMT-8', 'dstshortname' => null, 'longname' => 'GMT-08:00' ); $GLOBALS['_DATE_TIMEZONE_DATA']['Etc/GMT-9'] = array( 'offset' => -32400000, 'shortname' => 'GMT-9', 'dstshortname' => null, 'longname' => 'GMT-09:00' ); -----------
 [2009-06-05 16:57 UTC] cjr (Chris Rivas)
This is not a bug, POSIX style time zones work like this: http://bugs.php.net/bug.php?id=41869 https://bugzilla.redhat.com/show_bug.cgi?id=224442 '# 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).' PHP recommend not using these aliases: http://www.php.net/manual/en/timezones.others.php