Bug #54340 [Opn->Asn]: DateTime::add() method bug
Edit report at http://bugs.php.net/bug.php?id=54340&edit=1
ID: 54340
Updated by: aharvey@php.net
Reported by: 1cdecoder at gmail dot com
Summary: DateTime::add() method bug
-Status: Open
+Status: Assigned
Type: Bug
Package: Date/time related
Operating System: Windows 7 x64
PHP Version: 5.3.6
-Assigned To:
+Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
Looks like we don't reset the DateTime object's timelib_rel_time
structure properly before altering it in add() (and sub(), for that
matter), and the first_last_day_of flag is causing issues.
Fix forthcoming.
Previous Comments:
------------------------------------------------------------------------
[2011-03-22 00:29:12] 1cdecoder at gmail dot com
Description:
------------
DateTime::add() method bug
Test script:
---------------
$date = new DateTime('first day of this month');
echo $date->format('Y-m-d H:i:sP');
$date->add(new DateInterval('P1D'));
echo $date->format('Y-m-d H:i:sP');
Expected result:
----------------
2011-03-01 01:17:31+02:00
2011-03-02 01:17:31+02:00
Actual result:
--------------
2011-03-01 01:17:31+02:00
2011-03-01 01:17:31+02:00
=================
====== BUT ======
=================
$date = new DateTime('first day of this month');
echo $date->format('Y-m-d H:i:sP');
$date->add(new DateInterval('P1M'));
echo $date->format('Y-m-d H:i:sP');
Expected result:
----------------
2011-03-01 01:17:31+02:00
2011-04-01 01:17:31+02:00
Actual result:
--------------
2011-03-01 01:17:31+02:00
2011-04-01 01:17:31+02:00
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54340&edit=1
Thread (3 messages)