-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnowtime.html
51 lines (44 loc) · 1.27 KB
/
nowtime.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
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>当前系统时间</title>
<script type="text/javascript">
window.onload = function() {
showTime();
};
function showTime() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
minutes = checkTime(minutes);
seconds = checkTime(seconds);
var weekday = new Array(7);
weekday[0] = "星期日";
weekday[1] = "星期一";
weekday[2] = "星期二";
weekday[3] = "星期三";
weekday[4] = "星期四";
weekday[5] = "星期五";
weekday[6] = "星期六";
document.getElementById('show').innerHTML = year + "年" + month + "月" + day + "日" + " " + weekday[now.getDay()] + " " + hours + ":" + minutes + ":" + seconds;
setTimeout(showTime, 50);
}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
</script>
</head>
<body>
<div class="content1">
<div id="show">显示当前时间的位置</div>
</div>
</body>
</html>