Getting current unixtimestamp using Moment.js

前端 未结 4 1700
温柔的废话
温柔的废话 2021-01-30 05:57

I want to get the Unix TimeStamp using Moment.js. I can find many functions which convert timestamp to date in moment.js. I know that I can easily get the unix timestamp by usin

4条回答
  •  长发绾君心
    2021-01-30 06:41

    Try any of these

    valof = moment().valueOf();            // xxxxxxxxxxxxx
    getTime = moment().toDate().getTime(); // xxxxxxxxxxxxx
    unixTime =  moment().unix();           // xxxxxxxxxx
    formatTimex =  moment().format('x');   // xxxxxxxxxx
    unixFormatX = moment().format('X');    // xxxxxxxxxx
    

提交回复
热议问题