PHP指定日期范围循环输出日期
计算日期间隔天数: function diffBetweenTwoDays ($day1, $day2){ $second1 = strtotime($day1); $second2 = strtotime($day2); if ($second1 < $second2) { $tmp = $second2; $second2 = $second1; $second1 = $tmp; } return ($second1 - $second2) / 86400; } 循环输出日期示例: $date1="2021-11-01";//开始日期 $date2="2021-11-16";//结束日期 for ($me=0;$me<=diffBetweenTwoDays($date1, $date2);$me++){ $riqi=date("Y-m-d",(strtotime($date1)+86400*$me));//计算此时的日期 $sql = "select * from mdaima where shijian='" . $riqi . "' limit 1 "; 代码段... |