-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.html
More file actions
57 lines (44 loc) · 1.16 KB
/
clock.html
File metadata and controls
57 lines (44 loc) · 1.16 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function check(n) {
if (n < 10) {
return '0' + n;
} else {
return '' + n;
}
}
function updateTimer(){
//Date对象用于获取系统时间
var oDate = new Date();
var str = check(oDate.getHours()) + ":" + check(oDate.getMinutes()) + ":" + check(oDate.getSeconds());
//alert(str);
return str;
}
window.onload = function () {
var aTimerDiv = document.getElementById('timer');
setInterval(function(){
var str = updateTimer();
aTimerDiv.innerHTML=str;
},1000);
/*
年
getFullYear()
月
getMouth()
日
getDate()
星期
getDay()
*/
};
</script>
</head>
<body>
<div id="timer"></div>
</body>
</html>