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

From: Date: Fri, 22 Apr 2016 19:18:29 +0000
Subject: Bug #72080 [Opn->Fbk]: DateTime constructor ignoring Timezone
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200694@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: requinix@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: 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? Previous Comments: ------------------------------------------------------------------------ [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 (#200694) next »