How to split 24 hours into 5 minutes in the form of 12: 00, 12: 05, 12: 10, etc.?

Friends, please help with the solution. How to decompose 24 hours in increments of 5 minutes in the form of 12: 00, 12: 05, 12: 10, etc.?

Done for the chart!

There is such a solution by day:

$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
for($i=1;$i<=$num;$i++)
    $mktime=mktime(0,0,0,$month,$i,$year);
    $date=date("d/m",$mktime);
    $dates_month[$i]=$date;
    echo $date
}

Help me redo it.

Author: Виталина, 2015-01-20

3 answers

<?php
date_default_timezone_set('UTC');
$num = 86400/300;  // Секунд в дне поделить на секунды в 5 минутах
for($i=1;$i<=$num;$i++)
{
    $mktime = $i*300;
    $date=date("H:i",$mktime);
    $dates_month[$i]=$date;
    echo $date." ";
}
?>
 1
Author: Jbyh, 2015-01-21 07:47:31

Another option in the piggy bank

$today = new \DateTime('2014-01-21');
$tomorrow = new \DateTime('2014-01-22');
$interval = new \DateInterval('PT5M');
$daterange = new \DatePeriod($today, $interval ,$tomorrow);
foreach($daterange as $date){
    echo $date->format("H:i") . "\r\n";
}
 2
Author: flax, 2015-01-21 08:35:38

As an additional option

$step_array = '00:00';
while($i<288){
    $all_steps[] = $step_array; 
    $step_array = date('H:i', strtotime('+5 min', strtotime($step_array)));
    $i++;
}

var_dump($all_steps);
 1
Author: barseon, 2015-01-21 08:26:03