Edit report at https://bugs.php.net/bug.php?id=61530&edit=1

 ID:                 61530
 Comment by:         kavi at postpro dot net
 Reported by:        nicolas dot douillet at gmail dot com
 Summary:            DateTimeInterval subtracting wrong on summertime
                     Threshold
 Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   Debian / Linux
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

We can verify on 5.3.3 if that's worth anything.  This is a problem, please fix 
it.


Previous Comments:
------------------------------------------------------------------------
[2012-03-27 16:31:41] nicolas dot douillet at gmail dot com

Description:
------------
If you're using a timezone, like Europe/Paris, with summer and winter times, 
you 
will obtain a wrong result when adding and subtracting a time interval on a 
date 
at summertime threshold.

I fixed that issue by making all operations on GMT timezone.

Test script:
---------------
date_default_timezone_set('Europe/Paris');

/*
   Get a time just on the threshold
*/

$d = new DateTime("2012-03-25 03:00:00");
echo $d->format(DateTime::RFC2822) . "\n";

/*
    Substract one hour
*/

$i = new DateInterval("PT1H");
$d->sub($i);
echo $d->format(DateTime::RFC2822) . "\n";

Expected result:
----------------
Sun, 25 Mar 2012 03:00:00 +0200
Sun, 25 Mar 2012 01:00:00 +0100

Actual result:
--------------
Sun, 25 Mar 2012 03:00:00 +0200
Sun, 25 Mar 2012 03:00:00 +0200


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61530&edit=1

Reply via email to