具體如下:
下面的代碼通過Date對(duì)象的getTime()放回unix時(shí)間戳,即從1970年1月1日到當(dāng)前時(shí)間的秒數(shù)
<!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>
更多信息請(qǐng)查看IT技術(shù)專欄