<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="background: black;color: white;font-size: 30px;">
<span id="year">00</span>
年
<span id="month">00</span>
月
<span id="date">00</span>
日
星期
<span id="day">0</span>
<span id="hours">00</span>
:
<span id="minutes" >00</span>
:
<span id="seconds" >00</span>
<script>
var year = document.getElementById("year");
month = document.getElementById("month");
date = document.getElementById("date");
day = document.getElementById("day");
hours = document.getElementById("hours");
minutes = document.getElementById("minutes");
seconds = document.getElementById("seconds");
function fn(){
var date=new Date();
year.innerHTML = time(date.getFullYear());
month.innerHTML = time(date.getMonth()+1);
date.innerHTML = time(date.getDate());
day.innerHTML = time(date.getDay());
hours.innerHTML = time(date.getHours());
minutes.innerHTML = time(date.getMinutes());
seconds.innerHTML = time(date.getSeconds());
}
setInterval(function() {
fn();
}, 1000)
function time(str){
if(str<10) {
return "0" +str;
}else{
return str;
}
}
fn();
</script>
</body>
</html>