#51051 [Opn]: DateTime modify wrong result with DST change
From: mehdi dot rande at aliasource dot fr Date: Mon, 15 Feb 2010 10:56:45 +0000 Subject: #51051 [Opn]: DateTime modify wrong result with DST change References: 1 Groups: php.bugs Request: Send a blank email to php-bugs+get-147644@lists.php.net to get a copy of this message
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
Thread (21 messages)
- #51051 [Opn]: DateTime modify wrong result with DST change
- #51051 [Opn->Asn]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [PATCH]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Com]: DateTime modify wrong result with DST change
- Bug #51051 [Asn->Dup]: DateTime modify wrong result with DST change
| « previous | php.bugs (#147644) | next » |
|---|