项目中可能会给到你一个时间区间,比如2021-09-01到2021-09-21,然后需要把中间的时间范围读取出来,我们可以使用下面方法把时间范围显示出来。
// 获取指定范围内的日期
function periodDate($startDate, $endDate){
	$startTime = strtotime($startDate);
	$endTime = strtotime($endDate);
	$arr = [];
	while ($startTime <= $endTime)
	{
		$arr[] = date('Y-m-d', $startTime);
		$startTime = strtotime('+1 day', $startTime);
	}
	return $arr;
}使用方法:
// 获取时间区间 $time = periodDate($start,$end);
 
                     
                     
                                 
                                 
                         
                         
                         
                         
                         
                         
                         
                         
                
                 
                         
                         
                         
                         
                 关于简忆
关于简忆 简忆诞生的故事
简忆诞生的故事 
            


 粤ICP备16092285号
粤ICP备16092285号
文章评论(0)