date() help
Posted: Tue Feb 13, 2007 11:30 am
I am looking for a php function that will take in two dates and return an array (or something) with all the valid dates in between. Does anybody know of something that will do this?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
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;
}