-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdclock.php
50 lines (50 loc) · 1.01 KB
/
dclock.php
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
<html>
<head>
<style>
.clockStyle {
background-color:#000;
border:#999 2px inset;
padding:6px;
color:#0FF;
font-family:"Arial Black", Gadget, sans-serif;
font-size:16px;
font-weight:bold;
letter-spacing: 2px;
display:inline;
}
</style>
</head>
<body>
<!--<h2>Javascript CSS Digital Clock Tutorial</h2>-->
<div id="clockDisplay" class="clockStyle"></div>
<script>
function renderTime() {
var currentTime = new Date();
var diem = "AM";
var h = currentTime.getHours();
var m = currentTime.getMinutes();
var s = currentTime.getSeconds();
setTimeout('renderTime()',1000);
if (h == 0) {
h = 12;
} else if (h > 12) {
h = h - 12;
diem="PM";
}
if (h < 10) {
h = "0" + h;
}
if (m < 10) {
m = "0" + m;
}
if (s < 10) {
s = "0" + s;
}
var myClock = document.getElementById('clockDisplay');
myClock.textContent = h + ":" + m + ":" + s + " " + diem;
myClock.innerText = h + ":" + m + ":" + s + " " + diem;
}
renderTime();
</script>
</body>
</html>