PHP 日期计算函数【差异天数】

时间:2024-07-01 19:34:38
function count_days($a,$b){
$a_dt=getdate($a);
$b_dt=getdate($b);
$a_new=mktime(12,0,0,$a_dt['mon'],$a_dt['mday'],$a_dt['year']);
$b_new=mktime(12,0,0,$b_dt['mon'],$b_dt['mday'],$b_dt['year']);
return round(abs($a_new-$b_new)/86400);
}

  调用方式:

count_days(strtotime($e_time),strtotime($x_time));