[removed] Round Time UP nearest 5 minutes

前端 未结 6 1212
悲&欢浪女
悲&欢浪女 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:31

    var b = Date.now() + 15E4,
        c = b % 3E5;
        rounded = new Date(15E4>=c?b-c:b+3E5-c);
    

提交回复
热议问题