/**
* 获取两个时间格式相差的天数
* @date 2019/05/23
* @param $start_time int 开始时间戳
* @param $end_time int 结束时间戳
*/
public static function getTimeDiff($start_time, $end_time = null)
{
if (!is_numeric($start_time)) {
$start_time = strtotime($start_time);
}
if (!$end_time) {
$end_time = time();
}
if (!is_numeric($end_time)) {
$end_time = strtotime($end_time);
}
while ($start_time <= $end_time){
$days[] = date('Y-m-d',$start_time);
$start_time = strtotime('+1 day',$start_time);
}
return count($days);
}
网友评论