-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTime.html
52 lines (42 loc) · 1.15 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script>
function dateFormat(m){
m = m + "";
if(m.length == 1){
return "0"+m;
}
return m;
}
function TimeFormat(d){
var year = dateFormat(d.getYear()+1900);
var month = dateFormat(d.getMonth()+1);
var date = dateFormat(d.getDate());
var h = dateFormat(d.getHours());
var m = dateFormat(d.getMinutes());
var s = dateFormat(d.getSeconds());
if(h > 12){
return year+"年"+month+"月"+date+"日"+(h-12)+":"+m+":"+s+"PM";
}
return year+"年"+month+"月"+date+"日"+h+":"+m+":"+s+"AM";
}
function timeTest(){
var d = new Date();
var times = TimeFormat(d);
document.getElementById("d1").innerText = times;
//setTimeout("TimeTest()",1000);
setInterval("timeTest()",1000);
}
</script>
</head>
<body onload = "timeTest()">
<h2 color=turquoise>今天是<div id = "d1" style="display: inline"></div></h2>
</body>
</html>