Bug #63311 [Opn]: DateTime::add() adds wrong interval when switching from summer to winter time

From: Date: Fri, 19 Oct 2012 12:33:35 +0000
Subject: Bug #63311 [Opn]: DateTime::add() adds wrong interval when switching from summer to winter time
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174185@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63311&edit=1 ID: 63311 Updated by: pajoye@php.net Reported by: thomas dot mayer at 2bis10 dot de Summary: DateTime::add() adds wrong interval when switching from summer to winter time Status: Open Type: Bug -Package: date_time +Package: Date/time related Operating System: Windows 7, debian 6 PHP Version: 5.4.8 Block user comment: N Private report: N New Comment: Fix category, tak #2. Previous Comments: ------------------------------------------------------------------------ [2012-10-19 12:32:30] thomas dot mayer at 2bis10 dot de I switched Expected result and actual result. Expected result: -------------- 2013-10-27T01:45:00+02:00 1382831100 2013-10-27T02:00:00+02:00 1382832000 900 Actual result: ---------------- 2013-10-27T01:45:00+02:00 1382831100 2013-10-27T02:00:00+01:00 1382835600 4500 ------------------------------------------------------------------------ [2012-10-19 12:31:20] pajoye@php.net Fix cat ------------------------------------------------------------------------ [2012-10-19 12:30:18] thomas dot mayer at 2bis10 dot de Description: ------------ When adding an interval to a DateTime object in european summer time and the resulting date is in european winter time, an additional hour is added. Please note that we stay in summer time(+2) until 3:00:00 and then the clock is set to 02:00:00 winter time(+1). Test script: --------------- $date = new DateTime( '2013-10-27 01:45:00', new DateTimeZone('Europe/Berlin') ); $oldStamp=$date->getTimeStamp(); $interval=new DateInterval('PT15M'); echo $date->format('c')."\n"; echo $date->getTimeStamp()."\n"; $date->add($interval); echo $date->format('c')."\n"; echo $date->getTimeStamp()."\n"; echo $date->getTimeStamp()-$oldStamp; Expected result: ---------------- 2013-10-27T01:45:00+02:00 1382831100 2013-10-27T02:00:00+01:00 1382835600 4500 Actual result: -------------- 2013-10-27T01:45:00+02:00 1382831100 2013-10-27T02:00:00+02:00 1382832000 900 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63311&edit=1

« previous php.bugs (#174185) next »