87,910
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 410px;
height: 30px;
border: 5px solid #F00;
padding: 15px 10px;
background-color: #0F0;
margin: auto;
text-align: center;
}
</style>
</head>
<body>
<script>
window.onload=function(){
var div = document.querySelector('div');
var DayArray =['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
function showTime(){
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth();
var date = now.getDate();
var hour = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var day = now.getDay();
if(seconds<10){
seconds='0'+seconds;
}
if(minutes<10){
minutes='0'+minutes;
}
var time =year+'年'+month+'月'+date+'日'+' '+hour+'时'+minutes+'分'+seconds+'秒'+' '+DayArray[day];
div.innerHTML='当前系统时间:'+time;
setTimeout("showTime()",1000);
}
showTime();
}
</script>
<div></div>
</body>
</html>