#42489 [Asn->Opn]: Quirk in strtotime using 'next' relative keyword

From: Date: Fri, 24 Oct 2008 16:14:51 +0000
Subject: #42489 [Asn->Opn]: Quirk in strtotime using 'next' relative keyword
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130064@lists.php.net to get a copy of this message
ID: 42489 Updated by: jani@php.net Reported By: chet at somedec dot com -Status: Assigned +Status: Open Bug Type: Date/time related -Operating System: Linux +Operating System: * -PHP Version: 5.2.4 +PHP Version: 5.2CVS-2008-10-24 Assigned To: derick Previous Comments: ------------------------------------------------------------------------ [2008-05-13 03:38:34] toby dot matejovsky at gmail dot com The same problem occurs on PHP 5.2.5 on Mac OS 10.5. ------------------------------------------------------------------------ [2007-09-03 10:50:31] jani@php.net Assigned to the ext/date maintainer. :) ------------------------------------------------------------------------ [2007-08-30 15:50:24] chet at somedec dot com Description: ------------ Adding time (even zero) to a relative date using the "next" keyword fails. Reproduce code: --------------- <?php $day = date("l"); // Get what /today/ is. $plain = strtotime("Next $day"); $zweek = strtotime("Next $day + 0 weeks"); $incweek = strtotime("Next $day + 1 week"); $zmin = strtotime("Next $day + 0 weeks"); $incmin = strtotime("Next $day + 1 minute"); echo "Today is $day\n"; echo "Next $day is " . date(DATE_ATOM, $plain) . "\n"; echo ($zweek === $plain ? "PASS\t" : "FAIL\t") . "Next $day + 0 weeks is " . date(DATE_ATOM, $zweek) . "\n"; echo ($incweek !== $plain ? "PASS\t" : "FAIL\t") . "Next $day + 1 week is " . date(DATE_ATOM, $incweek) . "\n"; echo ($zmin === $plain ? "PASS\t" : "FAIL\t") . "Next $day + 0 minutes is " . date(DATE_ATOM, $zmin) . "\n"; echo ($incmin == ($plain + 60) ? "PASS\t" : "FAIL\t") . "Next $day + 1 minute is " . date(DATE_ATOM, $incmin) . "\n"; ?> Expected result: ---------------- The four tests should pass; none do. Actual result: -------------- Using the current day (according to your computer clock) in conjunction with the next keyword (i.e. "Next Thursday" when run on Thursday) correctly returns one week from the current date. However, adding or subtracting any amount of time results in an erroneous result of the /current date/ plus or minus the offset. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42489&edit=1

« previous php.bugs (#130064) next »