Answer: Use the
Date.now() method to generate the UTC timestamp in milliseconds (which is the number of milliseconds since midnight Jan 1, 1970).
ExampleTry this code »
// Creating a timestamp
var timestamp = Date.now();
// Converting it back to human-readable date and time
var d = new Date(timestamp);
Here are some more FAQ related to this topic: