Edit report at https://bugs.php.net/bug.php?id=51689&edit=1
ID: 51689 Updated by: ahar...@php.net Reported by: binarte at gmail dot com Summary: Date::diff keeps subtracting after Date::sub -Status: Feedback +Status: Closed Type: Bug Package: Date/time related Operating System: Ubuntu 10.04 PHP Version: 5.3.2 -Assigned To: +Assigned To: aharvey Block user comment: N Private report: N New Comment: Cheers; we'll call this fixed then. Previous Comments: ------------------------------------------------------------------------ [2012-03-09 07:38:26] php dot net at doppy dot nl 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. ------------------------------------------------------------------------ [2010-04-29 01:11:17] der...@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