PHP计算日期间隔天数:
function
diffBetweenTwoDays (
$day1
,
$day2
){
$second1
=
strtotime
(
$day1
);
$second2
=
strtotime
(
$day2
);
if
(
$second1
<
$second2
) {
$tmp
=
$second2
;
$second2
=
$second1
;
$second1
=
$tmp
;
}
return
(
$second1
-
$second2
) / 86400;
}
PHP指定日期范围循环输出日期示例:
$date1
=
"2021-11-01"
;
//开始日期
$date2
=
"2021-11-16"
;
//结束日期
$days =
diffBetweenTwoDays(
$date1
,
$date2
);
for
(
$me
= 0;
$me
<=
$days; $me
++){
代码段...
}