Bug #69916 [NEW]: DateTime and bad behaviour with DateTimeZone
From: marcus at onlab dot org
Operating system: osx
PHP version: 5.6.10
Package: Date/time related
Bug Type: Bug
Bug description:DateTime and bad behaviour with DateTimeZone
Description:
------------
Reproduced on PHP 5.6.10 (cli) (built: Jun 12 2015 10:07:24) osx Yosemit
10.10.3 Darwin Kernel Version 14.3.0, and PHP 5.5.23 (cli) (built: Mar
23 2015 01:47:37)
php.ini
date.timezone => UTC => UTC
Reproduced on Amazon machines: PHP 5.6.10-1+deb.sury.org~trusty+1 (cli)
Test script:
---------------
More cases: https://gist.github.com/onlab/71a863feed01f79e7b7a
$baseDate = \DateTime::createFromFormat(\DateTime::ISO8601,
'2015-06-23T18:00:00-0300');
echo '----- Everything works fine here -----' . PHP_EOL;
echo "SET America/Sao_Paulo \t" . $baseDate->format(\DateTime::ISO8601)
. PHP_EOL;
$baseDate->setTimezone(new \DateTimeZone('America/Sao_Paulo'));
echo "SET GMT-3 \t\t" . $baseDate->format(\DateTime::ISO8601) .
PHP_EOL;
$baseDate->setTimezone(new \DateTimeZone('GMT-3'));
echo "SET America/Sao_Paulo \t" . $baseDate->format(\DateTime::ISO8601)
. PHP_EOL;
$baseDate->setTimezone(new \DateTimeZone('America/Sao_Paulo'));
echo '----- Time will be changed -3 hours (bug) -----' . PHP_EOL;
echo "SET America/Sao_Paulo \t" . $baseDate->format(\DateTime::ISO8601)
. PHP_EOL;
$baseDate->setTimezone(new \DateTimeZone('America/Sao_Paulo'));
echo '----- Everything works fine here -----' . PHP_EOL;
echo "SET GMT-3 \t\t" . $baseDate->format(\DateTime::ISO8601) .
PHP_EOL;
$baseDate->setTimezone(new \DateTimeZone('GMT-3'));
Expected result:
----------------
Regardless of the timezone I'm using, both represents GMT-3. So the
result should be the below result in any result:
2015-06-23T18:00:00-0300
Actual result:
--------------
----- Everything works fine here -----
SET America/Sao_Paulo 2015-06-23T18:00:00-0300
SET GMT-3 2015-06-23T18:00:00-0300
SET America/Sao_Paulo 2015-06-23T18:00:00-0300
----- Time will be changed -3 hours (bug) -----
SET America/Sao_Paulo 2015-06-23T15:00:00-0300
----- Everything works fine here -----
SET GMT-3 2015-06-23T15:00:00-0300
--
Edit bug report at https://bugs.php.net/bug.php?id=69916&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69916&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69916&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69916&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69916&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69916&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69916&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69916&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69916&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69916&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69916&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69916&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69916&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69916&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69916&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69916&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69916&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69916&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69916&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69916&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69916&r=mysqlcfg
Thread (7 messages)
- marcus at onlab dot org