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

 ID:                 60237
 Updated by:         dani...@php.net
 Reported by:        s...@php.net
 Summary:            TLA timezone dates produce wrong results with
                     add/diff
-Status:             Assigned
+Status:             Duplicate
 Type:               Bug
 Package:            Date/time related
 Operating System:   *
 PHP Version:        5.4.0beta2
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

This is a duplicate of https://bugs.php.net/bug.php?id=55253.


Previous Comments:
------------------------------------------------------------------------
[2011-11-07 18:15:45] s...@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"
}



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



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

Reply via email to