首页 > 代码库 > PHP 获取两个日期之间的日期数组/月份数组

PHP 获取两个日期之间的日期数组/月份数组

function getEmptyArr($s_time,$e_time,$type){
	$tmp = array();
	if($type==‘day‘){
		$s_time = strtotime($s_time);
		$e_time = strtotime($e_time);
		while($e_time>=$s_time){
			$tmp[] = date(‘Y-m-d‘,$e_time);
			$e_time -= 86400;
		}
	}else if(‘month‘){
		$s_time = strtotime(date(‘Y-m‘,strtotime($s_time)));
		$e_time = strtotime(date(‘Y-m‘,strtotime($e_time)));
		while($e_time>=$s_time){
			$e_time_str = date(‘Y-m‘,$e_time);
			$tmp[] = $e_time_str;
			$e_time = strtotime("$e_time_str -1 month");
		}
	}
	return $tmp;
}

  

PHP 获取两个日期之间的日期数组/月份数组