我想做一个函数来给我一个时间范围的数组,如下所示:
// 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 .... ]
我该怎么做?
答案 0 :(得分:1)
$hourRange = range(strtotime('00:00'), strtotime('23:50'), 10 * 60);
foreach($hourRange as $time){
$date = date("H:i",$time);
echo $date . "\n";
}