<!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显示动态显示当前时间代码
最新推荐文章于 2021-02-19 20:37:34 发布