PHP round time() up (future) to next multiple of 5 minutes

前端 未结 4 2007
陌清茗
陌清茗 2021-01-02 07:16

How do I round the result of time() up (towards the future) to the next multiple of 5 minutes?

4条回答
  •  青春惊慌失措
    2021-01-02 07:49

     $now = time();     
     $next_five = ceil($now/300)*300;
    

    This will give you the next round five minutes (always greater or equal the current time).

    I think that this is what you need, based on your description.

提交回复
热议问题