实时更新,字丑见谅
计时器
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>计时器</title>
</head>
<body>
<h1 id = "time"></h1>
<script type='text/javascript'>
function time(){
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDate();
var hour = now.getHours();
var minutes = now.getMinutes();
var second = now.getSeconds();
document.getElementById("time").innerHTML = year +"-"+ month +"-"+ day +" "+ hour+":"+minutes+":"+second;
}
time();
setInterval("time()",1000);
</script>
</body>
</html>