Getting time in timestamp format in JavaScript

When working with dates, there is a special timestamp format that in JavaScript shows the number of milliseconds that have elapsed since 1st of January 1970 to the current (or given) point in time.

There is a special method getTime that can be used to get the time in timestamp format. Let's, for example, get the current time in this format:

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

Get the given time in timestamp format:

let date = new Date(2015, 11, 4, 23, 59, 59); console.log(date.getTime());

Display the timestamp corresponding to the date 1 of January 2025.

enru