|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-09-03 10:50 UTC] jani@php.net
[2008-05-13 03:38 UTC] toby dot matejovsky at gmail dot com
[2008-10-24 16:15 UTC] jani@php.net
[2009-05-03 14:08 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 12:00:01 2025 UTC |
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.