醉菜鸟 2021-08-07 11:35:23

php 计算两个日期相差天数的方法

/**
* 计算两个日期相差天数的方法
* @param $date1
* @param $data2
* @return float|int
*/
function diff_day($date1, $data2)
{
$second1 = strtotime($date1);
$second2 = strtotime($data2);

if ($second1 < $second2) {
$tmp = $second2;
$second2 = $second1;
$second1 = $tmp;
}

return ($second1 - $second2) / 86400;
}
意见反馈