moment.js get current time in milliseconds?

前端 未结 7 1128
旧巷少年郎
旧巷少年郎 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

    From the docs: http://momentjs.com/docs/#/parsing/unix-timestamp-milliseconds/

    So use either of these:


    moment(...).valueOf()

    to parse a preexisting date and convert the representation to a unix timestamp


    moment().valueOf()

    for the current unix timestamp

提交回复
热议问题