note 73217 deleted from function.date by felipe
| From: | felipe@php.net | Date: | Sat, 05 Jan 2008 01:56:53 +0000 |
| Subject: | note 73217 deleted from function.date by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134799@lists.php.net to get a copy of this message | ||
Note Submitter: mybenchmarkid at yahoo dot com
----
here is a function I wrote that was useful for a calendar application I was using.
It returns an array of the valid dates between two parameter dates. enjoy.
<?
function DatesBetween($startDate, $endDate){
// get the number of days between the two given dates.
$days = (strtotime($endDate) - strtotime($startDate)) / 86400 + 1;
$startMonth = date("m", strtotime($startDate));
$startDay = date("d", strtotime($startDate));
$startYear = date("Y", strtotime($startDate));
$dates;//the array of dates to be passed back
for($i=0; $i<$days; $i++){
$dates[$i] = date("n/j/Y", mktime(0, 0, 0, $startMonth , ($startDay+$i), $startYear));
}
return $dates;
}
?>
example: $dates = DatesBetween("2/27/2007","3/3/2007")
Array ( [0] => 2/27/2007 [1] => 2/28/2007 [2] => 3/1/2007 [3] => 3/2/2007 [4] =>
3/3/2007 )