This is a PHP function to get all the dates between two dates.
The function will return an array including both the starting and ending date.
The returned date format will be Year-month-date(YYYY-MM-DD) just as MySQL standard date format.
The function accepts two parameters
1. The start date.
2. The end date.
The input date format must acceptable by PHP strtotime function
The function will return an array including both the starting and ending date.
The returned date format will be Year-month-date(YYYY-MM-DD) just as MySQL standard date format.
The function accepts two parameters
1. The start date.
2. The end date.
The input date format must acceptable by PHP strtotime function
function datesBetween($start_date=null,$end_date=null)
{
$dates=array();
$dates[0]=date('Y-m-d',strtotime($start_date));
$secs=strtotime($start_date);
$i=1;
while($secs < strtotime($end_date))
{
$secs+=(24*60*60);
$dates[$i]= date('Y-m-d',$secs);
$i++;
}
return $dates;
}
Comments
Post a Comment