This is a simple snippet of code that will return an array of days between two dates.
Read on for a little more info…
// Start the variable off with the start date
$aDays[] = $sStartDate;
// Set a 'temp' variable, sCurrentDate, with
// the start date - before beginning the loop
$sCurrentDate = $sStartDate;
// While the current date is less than the end date
while($sCurrentDate < $sEndDate){
// Add a day to the current date
$sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate)));
// Add this new day to the aDays array
$aDays[] = $sCurrentDate;
}
// Once the loop has finished, return the
// array of days.
return $aDays;
}
?>
Usage:
You can use most date formats, such as:
or
Whatever strtotime can handle, you can pass to this function.
Hope it helps!
Saint!
Great and very usefull script..thank you
Thx buddy i really enjoyed this function… as i truely req. it in my proj….
Again thanking u….
Kudos to you dude. that saved me some time! thank you!
Thank you! This is exactly what I had been looking for.
This is exactly what i want..but it does not work well…i alway get this error
Fatal error: Maximum execution time of 30 seconds exceeded
i don't know why..!!!!i understand the code well but…
thanks alot..thanks for any help…
by the way….i use a logical two days!!!!!!!!!! the start date less than the end date and between them not more than 25 days..:(
Thanx a lot for the function