-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.html
126 lines (113 loc) · 3.27 KB
/
time.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>liumh</title>
<link rel="icon" type="image/x-icon" href="img/7.ico"/>
</head>
<style>
div#divTime{
width: auto;
font-size: 0pt;
text-align:center
}
#date{
margin: 300px 0 0 0;
}
b{
color:red;
font: 1em sans-serif;
font-size: 50pt;
}
a{
text-decoration:none
}
div#game{
font-size: 20pt;
text-align: center;
}
div#blog{
font-size: 20pt;
text-align: center;
}
div#game>p{
margin: 10px 0 0 0;
}
div#blog>p{
margin: 10px 0 0 0;
}
h3.game{
margin: 180px 0 0 0;
}
h3.blog{
margin: 20px 0 0 0;
}
</style>
<body>
<div id="divTime">
<div id="date">
<b class="time_show"></b><b>年</b>
<b class="time_show"></b><b>月</b>
<b class="time_show"></b><b>日</b>
<b> 星期</b><b id="day" class="time_show"></b>
</div>
<div id="time">
<b class="time_show"></b>
<b>:</b>
<b class="time_show"></b>
<b>:</b>
<b class="time_show"></b>
<b>.</b>
<b class="time_show"></b>
</div>
<div>
<b id="year"></b><b>年已经过去了</b><b id="percent"></b><b>%</b>
</div>
</div>
<script>
function getweek(day){
var week;
switch(day){
case 0: week = "日";break;
case 1: week = "一";break;
case 2: week = "二";break;
case 3: week = "三";break;
case 4: week = "四";break;
case 5: week = "五";break;
case 6: week = "六";break;
}
return week;
};
var myDate = new Date();
var time_show = document.getElementsByClassName("time_show");
var year_show = document.getElementById("year");
var percent = document.getElementById("percent");
setInterval(function(){
myDate = new Date();
var year = myDate.getFullYear();
time_show[0].innerText = year;
time_show[1].innerText = myDate.getMonth()+1;
time_show[2].innerText = myDate.getDate();
time_show[3].innerText = getweek(myDate.getDay());
time_show[4].innerText = myDate.getHours();
time_show[5].innerText = myDate.getMinutes();
time_show[6].innerText = myDate.getSeconds();
var ms = myDate.getMilliseconds();
if(ms < 10){
ms = ms + "00";
}else if(ms < 100){
ms = ms + "0";
}
time_show[7].innerText = ms;
year_show.innerText = year;
var nowTimeStamp = myDate.valueOf();
myDate.setFullYear(year, 0, 1);
myDate.setHours(0, 0, 0, 0);
var thisYearStamp = myDate.valueOf();
myDate.setFullYear(year+1, 0, 1);
var nextYearStamp = myDate.valueOf();
percent.innerText = ((nowTimeStamp - thisYearStamp) * 100 / (nextYearStamp - thisYearStamp)).toFixed(7);
},10);
</script>
</body>
</html>