php.net |  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: stas@php.net Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.4.0beta2 OS: *
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: stas@php.net
New email:
PHP Version: OS:

 

 [2011-11-07 18:15 UTC] stas@php.net
Description:
------------
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'); 
var_dump($start->format('U'));
$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);
var_dump($start->format('U'));
$res = $start->add($int);
var_dump($res);


Expected result:
----------------
.....

object(DateTime)#1 (3) {
  ["date"]=>
  string(19) "2010-06-06 18:38:28"
  ["timezone_type"]=>
  int(2)
  ["timezone"]=>
  string(3) "EDT"
}


Actual result:
--------------
.......

object(DateTime)#1 (3) {
  ["date"]=>
  string(19) "2010-06-06 17:38:28"
  ["timezone_type"]=>
  int(2)
  ["timezone"]=>
  string(3) "EDT"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-07 18:16 UTC] stas@php.net
-Assigned To: +Assigned To: derick
 [2011-11-21 02:16 UTC] danielc@php.net
-Status: Assigned +Status: Duplicate
 [2011-11-21 02:16 UTC] danielc@php.net
This is a duplicate of https://bugs.php.net/bug.php?id=55253.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC