| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
<?php
// This is a really fast and efficient code that finds only specific week days between two dates.
// In this example it finds all Tuesdays between May the 15th 2010 and June the 2nd 2010.
// If you wish to list all the dates between $startdate and $enddate simple remove the IF statement as told below ('remove this line').
// You may also use this code to get the number of days between two dates in a more efficient manner.
$startdate = strtotime('2010-05-15');
$enddate = strtotime('2010-06-02');
$weekday = "Tue";
$dates = array();
echo $weekday." happens on: <br />";
while($startdate <= $enddate)
{
if (stristr(date('D Y-m-d', $startdate), $weekday)) { // remove this line
array_push($dates, date('Y-m-d', $startdate));
} // remove this line
$startdate += 86400;
}
print_r($dates);
?>
----
Server IP: 81.88.49.3
Probable Submitter: 193.43.176.11
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/98003
Del: integrated -- https://master.php.net/note/delete/98003/integrated
Del: useless -- https://master.php.net/note/delete/98003/useless
Del: bad code -- https://master.php.net/note/delete/98003/bad+code
Del: spam -- https://master.php.net/note/delete/98003/spam
Del: non-english -- https://master.php.net/note/delete/98003/non-english
Del: in docs -- https://master.php.net/note/delete/98003/in+docs
Del: other reasons-- https://master.php.net/note/delete/98003
Reject -- https://master.php.net/note/reject/98003
Search -- https://master.php.net/manage/user-notes.php