You can use the method to get the UTC timestamp in milliseconds in all modern browsers.

const timestamp =

// 1630735687817

Alternatively, you could also use the getTime() method or the valueOf() method on Date to get the same timestamp:

const timestamp = new Date().getTime()
// OR
const timestamp = new Date().valueOf()

To convert the timestamp to seconds (UNIX time in UTC), you can do the following:

const unixTime = Math.floor( / 1000)