Date class provides methods to interact with dates and times. Usually, you need to put more effort into calculating the value that you’re interested in.
Here’s a code snippet showing you how to get the number of seconds since epoch:
const now = new Date() const secondsSinceEpoch = Math.round(now.getTime() / 1000)
.getTime() call gives you the milliseconds since epoch.
Convert them to seconds by dividing by 1000. This may create a decimal and you have to ensure an integer value by rounding to the next whole number. Otherwise, you may run into odd behavior when using the decimal value.