<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
</head>
<body>
<h1> </h1>
<h2 id='time'></h2>
</body>
<script>
window.οnlοad=function(){
function getCurrentDatetime() {
var pad = function (n) {
return n < 10 ? '0' + n : n;
}
date = new Date();
var nowt=date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate()) + ' ' + pad(date.getHours()) + ':' + pad(date.getMinutes()) + ':' + pad(date.getSeconds());
document.getElementById('time').innerHTML=nowt;
setTimeout(getCurrentDatetime,1000);
}
getCurrentDatetime();
}
</script>
</html>
JS顯示動態顯示當前時間代碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.