How to Generate a Timestamp in JavaScript

You can simply use JavaScript’s method to generate the UTC timestamp in milliseconds (which is the number of milliseconds since January 1, 1970).

The following example will show you how to get a timestamp and how to convert it back to a human-readable “date and time” format in JavaScript.

How to Generate a Timestamp in JavaScript
// Creation of the timestamp
var timestamp =;
// Convert timestamp to human readable date and time
var date = new Date(timestamp);


Date Wed May 05 2021 01:41:09 GMT+0000 (UTC)

The method is supported by all web browsers.

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *