Bug #72080 [NEW]: DateTime constructor ignoring Timezone

From: Date: Fri, 22 Apr 2016 18:53:06 +0000
Subject: Bug #72080 [NEW]: DateTime constructor ignoring Timezone
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200693@lists.php.net to get a copy of this message
From: matheusmalves at gmail dot com Operating system: CentOS PHP version: 7.0.5 Package: Date/time related Bug Type: Bug Bug description:DateTime constructor ignoring Timezone Description: ------------ When I create an object (DateTime), the second parameter (timezone) is ignored and uses UTC. The test script has a comparison with PHP 5.6. Test script: --------------- <?php date_default_timezone_set('UTC'); $dt = new DateTime('2016-04-22 17:00:00', new DateTimeZone('America/Sao_Paulo')); echo $dt->getTimestamp(); // Result: // 1461355200 (PHP 5.6.19) -> 04/22/2016 20:00 (UTC) // 1461344400 (PHP 7.0.5) -> 04/22/2016 17:00 (UTC) echo '<br />'; $dt = new DateTime('2016-04-22 20:00:00', new DateTimeZone('UTC')); $dt->setTimezone(new DateTimeZone('America/Sao_Paulo')); echo $dt->getTimestamp(); // Result: // 1461355200 (PHP 5.6.19) -> 04/22/2016 20:00 (UTC) // 1461355200 (PHP 7.0.5) -> 04/22/2016 20:00 (UTC) Expected result: ---------------- 1461355200 1461355200 Actual result: -------------- 1461344400 1461355200 -- Edit bug report at https://bugs.php.net/bug.php?id=72080&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72080&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72080&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72080&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72080&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72080&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72080&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72080&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72080&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72080&r=support Expected behavior: https://bugs.php.net/fix.php?id=72080&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72080&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72080&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72080&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72080&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72080&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72080&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72080&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72080&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72080&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72080&r=mysqlcfg

« previous php.bugs (#200693) next »