Bug #51689 [Com]: Date::diff keeps subtracting after Date::sub
| From: | php dot net at doppy dot nl | Date: | Fri, 09 Mar 2012 07:38:26 +0000 |
| Subject: | Bug #51689 [Com]: Date::diff keeps subtracting after Date::sub | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-168294@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=51689&edit=1
ID: 51689
Comment by: php dot net at doppy dot nl
Reported by: binarte at gmail dot com
Summary: Date::diff keeps subtracting after Date::sub
Status: Feedback
Type: Bug
Package: Date/time related
Operating System: Ubuntu 10.04
PHP Version: 5.3.2
Block user comment: N
Private report: N
New Comment:
Result on php 5.3.6:
------------------
Thu, 31 Dec 2009 00:00:00 +0000
Thu, 31 Dec 2009 00:00:00 +0000
Thu, 31 Dec 2009 00:00:00 +0000
Thu, 31 Dec 2009 00:00:00 +0000
Thu, 31 Dec 2009 00:00:00 +0000
Thu, 31 Dec 2009 00:00:00 +0000
---------------
This is the expected result.
Recommend closing this.
Previous Comments:
------------------------------------------------------------------------
[2010-04-29 01:11:17] derick@php.net
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2010-04-29 00:54:55] binarte at gmail dot com
Description:
------------
After executing a sub() on a DateTime object, for every call of diff(), both DateTime objects start
getting subtracted by the value that was passed on sub().
Test script:
---------------
date_default_timezone_set('GMT');
$t1 = new DateTime('2010-01-01 00:00:00');
$t2 = new DateTime('2010-01-01 00:00:00');
$dif = new DateInterval('P1D');
$t2->sub($dif);
$t1->sub($dif);
for ($x = 0; $x < 3; $x++) {
$t1->diff($t2);
echo $t1->format("r\n");
echo $t2->format("r\n");
echo "\n";
}
Expected result:
----------------
Fri, 01 Jan 2010 00:00:00 +0000
Fri, 01 Jan 2010 00:00:00 +0000
Fri, 01 Jan 2010 00:00:00 +0000
Fri, 01 Jan 2010 00:00:00 +0000
Fri, 01 Jan 2010 00:00:00 +0000
Fri, 01 Jan 2010 00:00:00 +0000
Actual result:
--------------
Wed, 30 Dec 2009 00:00:00 +0000
Wed, 30 Dec 2009 00:00:00 +0000
Tue, 29 Dec 2009 00:00:00 +0000
Tue, 29 Dec 2009 00:00:00 +0000
Mon, 28 Dec 2009 00:00:00 +0000
Mon, 28 Dec 2009 00:00:00 +0000
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=51689&edit=1