获取每天每个小时时间范围

//========== 每天每小时的时间格式 ============
$days = ceil(($end_time_stamp + 1 - $start_time_stamp) / 3600);
for($j = 0; $j < $days; $j++) {
    $date_start = $start_time_stamp + $j * 86400;
    $date_end = ($date_start + 86399) > $end_time_stamp ? $end_time_stamp : ($date_start + 86399);
    $hours = ceil(($date_end + 1 - $date_start) / 3600);
    for($i = 0; $i < $hours; $i++) {
        $hour_arr[] = date('H:00',$date_start + $i * 3600);
        // $start = $date_start + $i * 3600;
        // $end = $start + 3600 - 1;    
    }
}
//============================================

 

posted @ 2018-01-12 19:09  lonmy  阅读(515)  评论(0编辑  收藏  举报