刚写的代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
function clock(){
var time='';
var date=new Date();
var year=date.getFullYear();
var month=date.getMonth()+1;
var day=date.getDate();
weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
var week=weekday[date.getDay()];
time=date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
timestamp=year+"年"+month+"月"+day+"日"+week+time;
document.getElementById("atttime").innerHTML=timestamp;
// document.getElementById("atttime2").value=timestamp;
}
setInterval( clock,1000);
</script>
</head>
<body>
<p id="atttime"></p>
<!-- <input type="text" id="atttime2" style="height:50px ;width:400px"> -->
</body>
</html>