20, Jan 2023
Date() object to get the current timestamp. You can create a new
Date() object, and then call the
.getTime() method on it to get the timestamp in milliseconds.
var timestamp = new Date().getTime();
This will give you the current timestamp in milliseconds.
You can also use
Date.now() function to get the timestamp in milliseconds
var timestamp = Date.now();
Both of the above methods will give you the timestamp in milliseconds, you can convert it to seconds by dividing it by 1000.