每半小时生成一个持续时间为数组的结果



我想做一个函数来给我一个时间范围的数组,如下所示:

// passing FROM, TO ( times to the function ) 
function time( '11:00', '13:00' ) {
}

// i want to get it like the following 
[ 0 => '11:00', 1 => '11:30', '2' => '12:00', 3 => '12:30', 4 => '01:00' and so on .... ]

我该怎么做?

$hourRange = range(strtotime('00:00'), strtotime('23:50'), 10 * 60);
foreach($hourRange as $time){
    $date = date("H:i",$time);
    echo $date . "n";
}

https://gist.github.com/adililhan/cc172f0eed55f6968b10

相关内容

最新更新