Bug #66651 [NEW]: DateTime::getTimezone() has invalid values?

From: Date: Thu, 06 Feb 2014 02:04:27 +0000
Subject: Bug #66651 [NEW]: DateTime::getTimezone() has invalid values?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184177@lists.php.net to get a copy of this message
From: blaak at ensemble dot com Operating system: Mac OS 10 X PHP version: 5.4.24 Package: Date/time related Bug Type: Bug Bug description:DateTime::getTimezone() has invalid values? Description: ------------ --- From manual page: http://www.php.net/datetime.settimezone --- When I run the test script, $d2 does not have its timezone change, e.g. setTimezone() returns null. $d1->getTimezone() seems to be valid, although its name via getName() returns "-08:00" Could this be fixed? Also, it would be nice if all getName() values are valid for the DateTimeZone constructor as well, e.g. why can't this work: new DateTimeZone("-08:00") Test script: --------------- $d1 = new DateTime('2014-02-02T10:00-0800'); $d2 = new DateTime('2014-02-02T11:58+0000'); $d2->setTimezone($d1->getTimezone()); echo "d2: " . $d2->format(DateTime::W3C) . "\n"; Expected result: ---------------- d2: 2014-02-02-T03:58:00-0800 e.g. the time display is relative to the PST time zone. Actual result: -------------- d2: 2014-02-02T11:58:00+00:00 e.g. the timezone did not change, since setTimezone() did not succeed. -- Edit bug report at https://bugs.php.net/bug.php?id=66651&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66651&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66651&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66651&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66651&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66651&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66651&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66651&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66651&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66651&r=support Expected behavior: https://bugs.php.net/fix.php?id=66651&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66651&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66651&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66651&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66651&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66651&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66651&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66651&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66651&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66651&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66651&r=mysqlcfg

« previous php.bugs (#184177) next »