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

From: Date: Tue, 26 Apr 2016 17:56:32 +0000
Subject: Bug #72080 [Opn->Fbk]: DateTime constructor ignoring Timezone
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200787@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: cmb@php.net Reported by: matheusmalves at gmail dot com Summary: DateTime constructor ignoring Timezone -Status: Open +Status: Feedback Type: Bug Package: Date/time related Operating System: CentOS PHP Version: 7.0.5 Block user comment: N Private report: N New Comment: Which versions of the timezonedb are in use? Previous Comments: ------------------------------------------------------------------------ [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 (#200787) next »