JavaScript prints the method of the current time Unix timestamp

  • 2020-05-26 07:48:40
  • OfStack

The example in this article shows how JavaScript prints the current time Unix timestamp. Share with you for your reference. The details are as follows:

The following code puts back the unix timestamp, which is the number of seconds from January 1, 1970 to the current time, through the getTime() of the Date object

<!DOCTYPE html>
<p id="demo">
Click the button to display the number 
of milliseconds since midnight,
January 1, 1970.</p>
<button onclick="myFunction()">Try it</button>
function myFunction()
var d = new Date();
var x = document.getElementById("demo");

PS: about Unix timestamp operation, here again to recommend a site Unix timestamp conversion tool, also comes with all kinds of language (Python/PHP/Java/MySQL) Unix timestamp operation method:

Unix timestamp (timestamp) conversion tool: http: / / tools ofstack. com/code/unixtime

I hope this article is helpful for you to design javascript program.

Related articles: