|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60237 TLA timezone dates produce wrong results with add/diff
Submitted: 2011-11-07 18:15 UTC Modified: 2011-11-21 02:16 UTC
From: Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.4.0beta2 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2011-11-07 18:15 UTC]
If you diff two dates with TLA timezone (like EDT) and then add the interval back 
to the earliest date, you would not get the later date but instead the result will 
be one hour off. See example below.

Test script:
$start = new DateTime('2010-06-04 02:18:48 EDT'); 
$end   = new DateTime('2010-06-06 18:38:28 EDT');  
$ts = $end->format('U');
var_dump($start, $end);
$int = $start->diff($end);
var_dump($int, $start);
$res = $start->add($int);

Expected result:

object(DateTime)#1 (3) {
  string(19) "2010-06-06 18:38:28"
  string(3) "EDT"

Actual result:

object(DateTime)#1 (3) {
  string(19) "2010-06-06 17:38:28"
  string(3) "EDT"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-07 18:16 UTC]
-Assigned To: +Assigned To: derick
 [2011-11-21 02:16 UTC]
-Status: Assigned +Status: Duplicate
 [2011-11-21 02:16 UTC]
This is a duplicate of
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Mar 03 03:01:24 2021 UTC