Create a loop that will increase the time by one hour

advertisements

This question already has an answer here:

  • PHP add 45 Minutes to a Time with Loop [duplicate] 1 answer

I've spent so much time on trying to figure out how to create a loop that will echo time between given $start_time and $end_time incrementing it by one hour in format HH:MM. For example if i have $start_time = "09:00" and $end_time="15:00" the output should be like:

09:00

10:00

11:00

12:00

13:00

14:00

15:00

Any idea how to do it? I know i should use php timestamps and strtotime etc. by i have never used them, so i can't do anything, pls help...


Its been awhile since I've coded PHP but look at this link.
Note I posted this before the Question was edited.

while($starttime < $endtime)
{
    echo $starttime;
    $starttime = date_add($starttime, date_interval_create_from_date_string('1 hour'));
}