Bug #53225 [Opn->Dup]: add-Method of DateTime-class
Edit report at https://bugs.php.net/bug.php?id=53225&edit=1
ID: 53225
Updated by: danielc@php.net
Reported by: i dot sonderegger at meteonews dot ch
Summary: add-Method of DateTime-class
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: Mac OS X 10.5.8
PHP Version: 5.3SVN-2010-11-02 (snap)
-Assigned To:
+Assigned To: danielc
Block user comment: N
Private report: N
New Comment:
This is a duplicate of https://bugs.php.net/bug.php?id=55253
Previous Comments:
------------------------------------------------------------------------
[2010-11-02 08:41:25] i dot sonderegger at meteonews dot ch
Description:
------------
PHP-Version:
PHP 5.3.99-dev (cli) (built: Nov 1 2010 17:42:09)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies
If a timezone is passed in the time-string to the constructor of the DateTime-Object, a subsequent
add() call could result in incorrect results (if the add() call oversteps a daylight-saving time).
Test script:
---------------
// Gives expected result
$date = new DateTime('2010-10-31 01:00 CEST', new
DateTimeZone("Europe/Zurich"));
$date->setTimezone(new DateTimeZone('Europe/Zurich'));
$date->add(new DateInterval('PT3H'));
echo $date->format('Y-m-d H:i:sP')."\n";
// Doesn't give expected result
$date = new DateTime('2010-10-31 01:00 CEST', new
DateTimeZone("Europe/Zurich"));
$date->add(new DateInterval('PT3H'));
$date->setTimezone(new DateTimeZone('Europe/Zurich'));
echo $date->format('Y-m-d H:i:sP')."\n";
Expected result:
----------------
2010-10-31 04:00:00+01:00
2010-10-31 04:00:00+01:00
Actual result:
--------------
2010-10-31 04:00:00+01:00
2010-10-31 03:00:00+01:00
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53225&edit=1
Thread (2 messages)