Bug #72080 [Fbk->NoF]: DateTime constructor ignoring Timezone

From: Date: Sun, 08 May 2016 04:22:24 +0000
Subject: Bug #72080 [Fbk->NoF]: DateTime constructor ignoring Timezone
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200946@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72080&edit=1 ID: 72080 Updated by: php-bugs@lists.php.net Reported by: matheusmalves at gmail dot com Summary: DateTime constructor ignoring Timezone -Status: Feedback +Status: No Feedback Type: Bug Package: Date/time related Operating System: CentOS PHP Version: 7.0.5 Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2016-04-26 17:56:31] cmb@php.net Which versions of the timezonedb are in use? ------------------------------------------------------------------------ [2016-04-22 19:40:47] matheusmalves at gmail dot com Using the same code: 1461344400: 2016-04-22 17:00:00 UTC ------------------------------------------------------------------------ [2016-04-22 19:37:03] matheusmalves at gmail dot com Yes, the result is 1461344400. The function phpinfo() return this: https://i.imgsafe.org/1779570.png ------------------------------------------------------------------------ [2016-04-22 19:18:28] requinix@php.net https://3v4l.org/FEkCA Seems to be working fine. You're saying that the first half of that *exact* script (though I suggest trying my tweaked version) produces the timestamp 1461344400 in PHP 7? ------------------------------------------------------------------------ [2016-04-22 18:53:05] matheusmalves at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=72080&edit=1

« previous php.bugs (#200946) next »