获取一个月的所有周的时间范围
//获取指定日期所在月的各个周的时间范围 第一周 1号至7号 以此类推 function getWeekByDate($date) { $date = strtotime($date); //月初日期 $start_time = mktime(0, 0, 0, date('m', $date), '01', date('Y', $date)); //月末日期 $end_day = strtotime('+1 month -1 days', $start_time); //第一周结束日期 $end_time = strtotime('+6 days', $start_time); while ($end_time <= $end_day) { $data[] = [ 'start_time' => date('Y-m-d', $start_time), 'end_time' => date('Y-m-d', $end_time) ]; $start_time = strtotime('+1 days', $end_time); $end_time = strtotime('+6 days', $start_time); } if ($start_time <= $end_day) { $end_time = $end_day; $data[] = [ 'start_time' => date('Y-m-d', $start_time), 'end_time' => date('Y-m-d', $end_time) ]; } return $data; }