Skip to content
Advertisement

Tag: date-arithmetic

How do I get a timestamp in JavaScript?

I want a single number that represents the current date and time, like a Unix timestamp. Answer Timestamp in milliseconds To get the number of milliseconds since Unix epoch, call Date.now: Alternatively, use the unary operator + to call Date.prototype.valueOf: Alternatively, call valueOf directly: To support IE8 and earlier (see compatibility table), create a shim for Date.now: Alternatively, call getTime

Advertisement