How do you get a timestamp in JavaScript?

前端 未结 30 3087
情深已故
情深已故 2020-11-21 15:19

How can I get a timestamp in JavaScript?

Something similar to Unix timestamp, that is, a single number that represents the current time and date. Either as a number

30条回答
  •  梦如初夏
    2020-11-21 15:37

    Moment.js can abstract away a lot of the pain in dealing with Javascript Dates.

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

    moment().unix();
    

提交回复
热议问题