1. 程式人生 > >PHP日期遍歷

PHP日期遍歷

function date_range($date1,$date2){
	$timestamp1=strtotime($date1);
	$timestamp2=strtotime($date2);
	$days=($timestamp2-$timestamp1)/86400+1;
	$date=[];
	for($i=0;$i<$days;$i++){
		$date[]=date('Y-m-d',$timestamp1+(86400*$i));
	}
	return $date;
}