[removed] Round Time UP nearest 5 minutes

前端 未结 6 1218
悲&欢浪女
悲&欢浪女 2021-01-06 21:59

I need to be able to round time to the next nearest 5 minutes.

Time now 11:54 - clock is 11:55

Time now 11:56 - clock is 12:00

<
6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-06 22:41

    You could divide out 5, do a Math.ceil then multiply back up by 5

    minutes = (5 * Math.ceil(minutes / 5));
    

提交回复
热议问题