ID: 51051
User updated by: mehdi dot rande at aliasource dot fr
Reported By: mehdi dot rande at aliasource dot fr
Status: Open
Bug Type: Date/time related
Operating System: Linux
PHP Version: 5.3.1
New Comment:
Sorry the expected result is in fact the actual result, and the actual
result is the expected result.
Previous Comments:
------------------------------------------------------------------------
[2010-02-15 10:55:19] mehdi dot rande at aliasource dot fr
Description:
------------
When adding seconds (or minutes or hours) to a datetime via the modify
method, if the date before modification is before the DST change and
the
date after modification is after the DST change, the date after
modification will be wrong.
php 5.2 seems to be affected too.
Reproduce code:
---------------
<?php
$dateBefore = new DateTime("2012-10-27 12:00:00", new
DateTimezone("Europe/Paris"));
var_dump($dateBefore->format('c'));
// DST change : 2012-10-28 01:00:00
$dateAfter = new DateTime("2012-10-28 12:00:00", new
DateTimezone("Europe/Paris"));
var_dump($dateAfter->format('c'));
$diff = $dateAfter->format('U') - $dateBefore->format('U');
var_dump($diff); // === 25 hours,
$dateBefore->modify('+'.$diff.' seconds');
var_dump($dateBefore->format('c'));
?>
Expected result:
----------------
string(25) "2012-10-27T12:00:00+02:00"
string(25) "2012-10-28T12:00:00+01:00"
int(90000)
string(25) "2012-10-28T13:00:00+01:00"
Actual result:
--------------
string(25) "2012-10-27T12:00:00+02:00"
string(25) "2012-10-28T12:00:00+01:00"
int(90000)
string(25) "2012-10-28T12:00:00+01:00"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=51051&edit=1