Php 每半小时生成一个持续时间为的数组
我想做一个函数,给我一个时间范围数组,如下所示:Php 每半小时生成一个持续时间为的数组,php,Php,我想做一个函数,给我一个时间范围数组,如下所示: // 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
// 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";
}
这里已经回答了: