JavaScript prints the method of the current time Unix timestamp


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>
<html>
<body>
<p id="demo">
Click the button to display the number
of milliseconds since midnight,
January 1, 1970.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var d = new Date();
var x = document.getElementById("demo");
x.innerHTML=d.getTime();
}
</script>
</body>
</html>

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.