php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61530 DateTimeInterval subtracting wrong on summertime Threshold
Submitted: 2012-03-27 16:31 UTC Modified: 2017-03-19 10:14 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: nicolas dot douillet at gmail dot com Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.3.10 OS: Debian / Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nicolas dot douillet at gmail dot com
New email:
PHP Version: OS:

 

 [2012-03-27 16:31 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-16 23:51 UTC] kavi at postpro dot net
We can verify on 5.3.3 if that's worth anything.  This is a problem, please fix 
it.
 [2014-01-17 13:59 UTC] jimmyraynor at gmail dot com
Ran into this issue with PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
TZ: date.timezone => America/Santiago
Between dates 2013-09-08 and 2014-01-15
Using OS: Mac Os 10.9

Funny fact is that I have three servers doing the same operation and only my mac returns different.
 [2014-01-17 14:57 UTC] derick@php.net
-Assigned To: +Assigned To: derick
 [2017-03-19 10:14 UTC] heiglandreas@php.net
-Status: Assigned +Status: Duplicate
 [2017-03-19 10:14 UTC] heiglandreas@php.net
We're now tracking this in https://bugs.php.net/bug.php?id=74274
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC