How do you get a timestamp in JavaScript?

前端 未结 30 3151
情深已故
情深已故 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:32

    One I haven't seen yet

    Math.floor(Date.now() / 1000); // current time in seconds
    

    Another one I haven't seen yet is

    var _ = require('lodash'); // from here https://lodash.com/docs#now
    _.now();
    

提交回复
热议问题