From: mehdi dot rande at aliasource dot fr
Operating system: Linux
PHP version: 5.3.1
PHP Bug Type: Date/time related
Bug description: DateTime modify wrong result with DST change
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 bug report at http://bugs.php.net/?id=51051&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51051&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51051&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51051&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51051&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=51051&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51051&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=51051&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=51051&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=51051&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=51051&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=51051&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=51051&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=51051&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51051&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51051&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51051&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=51051&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=51051&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=51051&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=51051&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=51051&r=mysqlcfg