note 70173 modified in function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 08 Apr 2007 13:00:05 +0000 |
| Subject: | note 70173 modified in function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125208@lists.php.net to get a copy of this message | ||
The following might produce something different than you might expect:
<?php
echo date('l, F jS Y', strtotime("third wednesday",
strtotime("2006-11-01"))) . "<br>";
echo date('l, F jS Y', strtotime("third sunday",
strtotime("2006-01-01")));
?>
Produces:
Wednesday, November 22nd 2006
Sunday, January 22nd 2006
The problem stems from strtotime when the requested day falls on the date passed to strtotime. If
you look at your calendar you will see that they should return:
Wednesday, November 15th 2006
Sunday, January 15th 2006
Because the date falls on the day requested it skips that day.
--was--
The following produces the wrong results:
<?php
echo date('l, F jS Y', strtotime("third wednesday",
strtotime("2006-11-01"))) . "<br>";
echo date('l, F jS Y', strtotime("third sunday",
strtotime("2006-01-01")));
?>
Produces:
Wednesday, November 22nd 2006
Sunday, January 22nd 2006
The problem stems from strtotime when the requested day falls on the date passed to strtotime. If
you look at your calendar you will see that they should return:
Wednesday, November 15th 2006
Sunday, January 15th 2006
Because the date falls on the day requested it skips that day.
http://php.net/manual/en/function.strtotime.php