How do I get a timestamp in JavaScript?

Timestamp in milliseconds

To get the number of milliseconds since Unix epoch, call Date.now

Date.now()

 

Date.prototype.valueOf()

The valueOf() method returns the primitive value of a Date object.

Alternatively, use the unary operator + to call Date.prototype.valueOf

+ new Date()

 

Date.prototype.valueOf()

The valueOf() method returns the primitive value of a Date object.

Alternatively, call valueOf directly:

new Date().valueOf()

Tags:

Share:

Related posts