I'm trying to get hours between a range of hours, example:
I have 2 hours: 23:00:00
(The start) and 01:00:00
(The end)
Now, through a for loop, I try to get the initial time from 30 to 30 minutes until it reaches the end. Example:
23:00:00
23:30:00
00:00:00
00:30:00
01:00:00
I am using the following script:
public function test($horas){
for($i=0;$i<count($horas);$i++){
for($j=$horas[$i]->hora_ini;
$j <= $hora[$i]->hora_fin;
$j = date("H:i:s", strtotime($j)+(30*60))){
echo $j.'<br />';
}
}
}
But it does not work, it only works when there are hours for example from 08:00:00
to 14:00:00
but not from 23:00:00
to 01:00:00