creating a loop for time incremented by 15 minutes

后端 未结 8 2031
猫巷女王i
猫巷女王i 2020-12-29 13:23

i\'m trying to make a loop that will output this:

08:00
08:15
08:30
08:45
09:00
09:15
09:30
09:45

i need it to go from 08:00 to 17:00

相关标签:
8条回答
  • 2020-12-29 13:51

    it can also be done with the range function

    <?php
    date_default_timezone_set("Europe/London");
    $range=range(strtotime("08:00"),strtotime("17:00"),15*60);
    foreach($range as $time){
            echo date("H:i",$time)."\n";
    }
    ?>
    

    so you don't have a loop, it just makes an array for you (my loop is just to print it out whilst formatting it)

    0 讨论(0)
  • 2020-12-29 13:51
    echo_datelist(17, 0, $day, $month, $year);
    

    Move that line to just after the outermost for-loop.

    0 讨论(0)
提交回复
热议问题