How to get time in milliseconds since the Unix epoch in JavaScript?

The standard Unix epoch is an expression in seconds. The Unix epoch or Unix time is the number of seconds elapsed since January 1, 1970.

The getTime() method is used to return the millisecond representation of the Date object.

To get time in milliseconds, use the following:

var milliseconds = (new Date).getTime();