Date.getTime

getTime – Get the number of milliseconds since 1 Jan 1970.

Description

Date.getTime()

Return values

Integer

Examples

Example #1 – getTime example

Get the current number of milliseconds since 1 Jan 1970

var date = new Date(); console.log(date.getTime());

The time can be rounded to the closest whole second by using the math object.

var date = new Date(); console.log(Math.round(date.getTime() / 1000));

External references