ID: 20382
Updated by: derick@php.net
Reported By: nickj-phpbugs at nickj dot org
-Status: Assigned
+Status: Closed
Bug Type: Date/time related
Operating System: *
PHP Version: 5CVS, 4CVS (2004-04-13)
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.
Fixed for PHP 5.1
Previous Comments:
------------------------------------------------------------------------
[2004-12-12 06:49:44] sid0007 at gmailll dot com
I verified this in php version 4.3.3
http://www.bonkee.com/Strtotime.php
------------------------------------------------------------------------
[2004-10-20 20:14:16] joe at dataport dot tv
Oh, also forgot to mention that while "next monday" does not work,
"next tuesday" does. There's definately a bug here, if "this monday"
works and "next tuesday" works, it seems to me that "next monday"
should work as well and that it's not just some time zone issue.
------------------------------------------------------------------------
[2004-10-19 21:30:21] joe at dataport dot tv
How's this?
<?php
$day=date("w",strtotime("this monday"));
echo $day;
?>
Outputs: 1
<?php
$day=date("w",strtotime("next monday"));
echo $day;
?>
Outputs: 0
I was going to submit a seperate bug but this definately looks related
even though this is a totally different way of going about getting the
same type of problem.
(I knew Mondays were a little odd, but does strtotime seem to think the
sunday of the next week has an extra second after midnight? As this
example demonstrates it doesn't do it if you prefix the weekday with
"this", just "next" or no prefix at all.)
------------------------------------------------------------------------
[2004-04-08 10:13:10] derick@php.net
This one shows it better:
<?php
putenv("TZ=Europe/Amsterdam");
$tStamp = mktime (17, 17, 17, 10, 27, 2004);
echo "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n";
$strtotime_timestamp = strtotime ("Monday", $tStamp);
echo "result=". date("l Y-m-d H:i:s T", $strtotime_timestamp).
"\n";
echo "wanted=Monday 2004-11-01 00:00:00 CET\n";
?>
------------------------------------------------------------------------
[2004-04-08 07:15:26] nickj-phpbugs at nickj dot org
How's this for a short and simple test script?
Applies strtotime() to every day between 1970 and 2037, and gives a
list of everything that looks wrong.
======================================================
<?php
$request_day = "Monday";
for ($i=1; ; $i++) {
// start at year 1970, bail out at year 2038
$tStamp = mktime (17,17,17,1,$i,1970);
if (date("Y", $tStamp) == 2038) break;
// request a day, check what we got, complain if differs
$strtotime_timestamp = strtotime ($request_day, $tStamp);
$result_day = date("l", $strtotime_timestamp);
if ($result_day != $request_day)
print "strtotime wrong on: " . date("j-M-Y", $tStamp) .
" - gave a $result_day, not a $request_day.\n";
}
?>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/20382
--
Edit this bug report at http://bugs.php.net/?id=20382&edit=1