//可预订小时范围$hour = [];for ($i=$startHour*3600;$i<=$endHour*3600;$i+=1800){//以半小时为单位输出$startHourItem = date('H:i',strtotime(date('Y-m-d'))+$i);//小时开始$endHourItem = date('H:i',strtotime(date('Y-m-d'))+$i+1800);//当前时间再加半小时$hourItemStr = $startHourItem.'-'.$endHourItem;//用于展示的数组//用于数据库查询的两个变量$startHour = date('Hi',strtotime(date('Y-m-d'))+$i);$endHour = date('Hi',strtotime(date('Y-m-d'))+$i+1800);$hour[]=['start_hour' => $startHour,'end_hour' => $endHour,'hour_str' => $hourItemStr,];}return $hour;
输出结构