moment.js get current time in milliseconds?

前端 未结 7 1150
旧巷少年郎
旧巷少年郎 2021-02-01 11:54
var timeArr = moment().format(\'HH:mm:ss\').split(\':\');

var timeInMilliseconds = (timeArr[0] * 3600000) + (timeArr[1] * 60000);

This solution works,

7条回答
  •  遇见更好的自我
    2021-02-01 12:16

    See this link http://momentjs.com/docs/#/displaying/unix-timestamp-milliseconds/

    valueOf() is the function you're looking for.

    Editing my answer (OP wants milliseconds of today, not since epoch)

    You want the milliseconds() function OR you could go the route of moment().valueOf()

提交回复
热议问题