incrementing time 15 minutes within loop

后端 未结 2 1511
故里飘歌
故里飘歌 2021-01-26 13:21

I want to create a dropdown that will take current time as start time and will end up till 24 hours, like till coming 24 hours so in between it will show time of every 15 minute

2条回答
  •  孤独总比滥情好
    2021-01-26 13:56

    You can use DateTime for that:

    $now = new DateTime();
    $end = clone $now;
    $end->modify("+24 hours");
    
    while ($now <= $end) {
        echo "";
        $now->modify('+15 minutes');
    }
    

提交回复
热议问题