How to get time in milliseconds since the unix epoch in Javascript? [duplicate]

Date.now() returns a unix timestamp in milliseconds.

const now = Date.now(); // Unix timestamp in milliseconds
console.log( now );

Prior to ECMAScript5 (I.E. Internet Explorer 8 and older) you needed to construct a Date object, from which there are several ways to get a unix timestamp in milliseconds:

console.log( +new Date );
console.log( (new Date).getTime() );
console.log( (new Date).valueOf() );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)