|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-29 01:11 UTC] derick@php.net
-Status: Open
+Status: Feedback
[2010-04-29 01:11 UTC] derick@php.net
[2012-03-09 07:38 UTC] php dot net at doppy dot nl
[2012-03-09 07:49 UTC] aharvey@php.net
-Status: Feedback
+Status: Closed
-Assigned To:
+Assigned To: aharvey
[2012-03-09 07:49 UTC] aharvey@php.net
[2012-03-09 07:49 UTC] aharvey@php.net
-Assigned To: aharvey
+Assigned To: derick
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 13:00:01 2025 UTC |
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