How to Generate a Timestamp in JavaScript

  1590 views   1 year ago Javascript

Use the Method

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

The following example demonstrates how to get a timestamp and how to convert it back to the human-readable date and time format in JavaScript.

// Creating a timestamp
var timestamp =;
// Converting it back to human-readable date and time
var d = new Date(timestamp);


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]

Related Articles