|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-21 03:06 UTC] danielc@php.net
[2011-11-21 03:06 UTC] danielc@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: danielc
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 21:00:02 2025 UTC |
Description: ------------ PHP-Version: PHP 5.3.99-dev (cli) (built: Nov 1 2010 17:42:09) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies If a timezone is passed in the time-string to the constructor of the DateTime-Object, a subsequent add() call could result in incorrect results (if the add() call oversteps a daylight-saving time). Test script: --------------- // Gives expected result $date = new DateTime('2010-10-31 01:00 CEST', new DateTimeZone("Europe/Zurich")); $date->setTimezone(new DateTimeZone('Europe/Zurich')); $date->add(new DateInterval('PT3H')); echo $date->format('Y-m-d H:i:sP')."\n"; // Doesn't give expected result $date = new DateTime('2010-10-31 01:00 CEST', new DateTimeZone("Europe/Zurich")); $date->add(new DateInterval('PT3H')); $date->setTimezone(new DateTimeZone('Europe/Zurich')); echo $date->format('Y-m-d H:i:sP')."\n"; Expected result: ---------------- 2010-10-31 04:00:00+01:00 2010-10-31 04:00:00+01:00 Actual result: -------------- 2010-10-31 04:00:00+01:00 2010-10-31 03:00:00+01:00