#43051 [NEW]: new DateTime doesn't work well with @timestamp and timezone

From: Date: Sat, 20 Oct 2007 07:35:05 +0000
Subject: #43051 [NEW]: new DateTime doesn't work well with @timestamp and timezone
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118751@lists.php.net to get a copy of this message
From: cezary at dodgeit dot com Operating system: Mac OS X PHP version: 5.2.4 PHP Bug Type: Date/time related Bug description: new DateTime doesn't work well with @timestamp and timezone Description: ------------ DateTime constructor fails to work well for me when using timestamps and time zones. $d = new DateTime('@1192864176', new DateTimeZone('America/ New_York')); echo $d->format(DATE_RFC3339); // outputs 2007-10-20T07:09:36+01:00 // why not -04:00? $d = new DateTime('@1192864176', new DateTimeZone('Antarctica/ Vostok')); echo $d->format(DATE_RFC3339); // outputs 2007-10-20T07:09:36+00:00 // why not +06:00? Besides it reports New York to be shifted +1 from UTC, it returns unadjusted time - it's 7 AM in UTC+1 and 7AM in UTC+0. A timestamp is always in UTC, but the resulting DateTime should be adjusted according to the given time zone in my opinion. My system clock and TZ environment variable are set to UTC. Reproduce code: --------------- $d = new DateTime('@1192864176', new DateTimeZone('America/ New_York')); echo $d->format(DATE_RFC3339); $d = new DateTime('@1192864176', new DateTimeZone('Antarctica/ Vostok')); echo $d->format(DATE_RFC3339); Expected result: ---------------- // 2007-10-20T03:09:36-04:00 // 2007-10-20T13:09:36+06:00 Actual result: -------------- // 2007-10-20T07:09:36+01:00 // 2007-10-20T07:09:36+00:00 -- Edit bug report at http://bugs.php.net/?id=43051&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43051&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43051&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43051&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43051&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43051&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43051&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43051&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43051&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43051&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43051&r=support Expected behavior: http://bugs.php.net/fix.php?id=43051&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43051&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43051&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43051&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43051&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43051&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43051&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43051&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43051&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43051&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43051&r=mysqlcfg

« previous php.bugs (#118751) next »