-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.html
43 lines (39 loc) · 1.37 KB
/
clock.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"
content="width=device-width, initial-scal=1.0, minimum-scal=1.0, maximum-scale=1.0, user-scalable=no">
<title>
Kindle Clock
</title>
<body>
<div id="main" style="background: white;">
<div id="date" align="center" style="font-size: 140px;margin-top: 40px;"></div>
<div id="week" align="center" style="font-size: 160px;margin-top: 40px;"></div>
<div id="time" align="center" style="font-size: 360px;margin-top: 40px;"></div>
</div>
</body>
<script>
window.onload = function () {
update()
}
var weekDays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
setInterval(function () {
update()
}, 60 * 1000)
function update() {
var d = new Date()
d = new Date(d.getTime() + (d.getTimezoneOffset() + 480) * 60 * 1000)
document.getElementById("date").innerHTML = d.getFullYear() + "-" + addZero(d.getMonth() + 1) + "-" + addZero(d.getDate());
document.getElementById("week").innerHTML = weekDays[d.getDay()];
document.getElementById("time").innerHTML = addZero(d.getHours()) + ":" + addZero(d.getMinutes());
}
function addZero(x) {
if (x - 0 < 10) {
return "0" + "" + x
} else {
return "" + x
}
}
</script>
</html>