ID:               42489
 Updated by:       [email protected]
 Reported By:      chet at somedec dot com
-Status:           Assigned
+Status:           Open
 Bug Type:         Date/time related
 Operating System: *
 PHP Version:      5.2CVS-2008-10-24
 Assigned To:      derick
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

This is fixed for PHP 5.3, I get the correct output:

Today is Sunday
Next Sunday is 2009-05-10T00:00:00+02:00
PASS    Next Sunday + 0 weeks is 2009-05-10T00:00:00+02:00
PASS    Next Sunday + 1 week is 2009-05-17T00:00:00+02:00
PASS    Next Sunday + 0 minutes is 2009-05-10T00:00:00+02:00
PASS    Next Sunday + 1 minute is 2009-05-10T00:01:00+02:00



Previous Comments:
------------------------------------------------------------------------

[2008-10-24 16:15:15] [email protected]

Still fails.

------------------------------------------------------------------------

[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] [email protected]

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

Reply via email to