round up/ round down a momentjs moment to nearest minute

后端 未结 10 1420
一整个雨季
一整个雨季 2020-12-05 01:47

How do you round up/ round down a momentjs moment to nearest minute?

I have checked the docs, but there doesn\'t appear to be a method for this.

Note that I

10条回答
  •  有刺的猬
    2020-12-05 02:04

    Just another possibility:

    var now = moment();
    // -> Wed Sep 30 2015 11:57:20 GMT+0200 (CEST)
    now.add(1, 'm').startOf('minute');
    // -> Wed Sep 30 2015 11:58:00 GMT+0200 (CEST)
    

提交回复
热议问题