|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-15 22:08 UTC] troy_rudolph at bridge360 dot com
-Status: Open
+Status: Closed
[2016-03-15 22:08 UTC] troy_rudolph at bridge360 dot com
[2016-03-15 23:35 UTC] requinix@php.net
-Status: Closed
+Status: Not a bug
[2016-03-15 23:35 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 23:00:02 2026 UTC |
Description: ------------ Adding a year to a DateTime produces different results for different timezone. IMO, the test script below should produce two identical date/time strings. However, the actual results are an hour apart. Expected: 03/12/2016 12:00 am 03/12/2016 12:00 pm Actual: 03/12/2016 12:00 am 03/11/2016 11:00 pm Thank you! Test script: --------------- <?php $ct = new \DateTimeZone('America/Chicago'); $utc = new \DateTimeZone('UTC'); $oneYear = new \DateInterval('P1Y'); $date1 = \DateTime::createFromFormat('Y-m-d H:i:s', '2015-03-12 00:00:00', $ct); $date1->add($oneYear); echo "\n". $date1->format("m/d/Y h:i a"); $date2 = \DateTime::createFromFormat('Y-m-d H:i:s', '2015-03-12 00:00:00', $ct); $date2->setTimezone($utc); $date2->add($oneYear); $date2->setTimezone($ct); echo "\n". $date2->format("m/d/Y h:i a"); Expected result: ---------------- Expected: 03/12/2016 12:00 am 03/12/2016 12:00 pm Actual result: -------------- Actual: 03/12/2016 12:00 am 03/11/2016 11:00 pm