forked from dneuman/clock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (46 loc) · 1.64 KB
/
index.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>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name=”apple-mobile-web-app-capable” content=”yes“>
<meta name=”mobile-web-app-capable” content=”yes“>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var d = today.getDate();
var w = today.getDay();
var day = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
m = checkTime(m);
// Format for 12-hour clock instead of default 24-hour clock.
// Remove these two lines for 24-hour clock.
var sep = getSep(h); // use sep to indicate am/pm.
if (h > 12) {h -= 12}; // use 12-hour clock
if (h == 0) {h = 12};
var theTime = h + sep + m
var theDate = day[w] + ' ' + d
document.getElementById('text').innerHTML = theTime;
document.getElementById('date').innerHTML = theDate;
var t = setTimeout(startTime, 1000); // 1-sec repeat
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
function getSep(h) {
var sep = '.';
if (h >= 12) {sep = ':'}; // use ':' for pm values, '.' for am
return sep;
}
</script>
</head>
<body onload="startTime()" style="background-color:black;">
<div id="date" style="color:white; font-family:sans-serif;
font-size:100px; text-align:right;
padding-top:120px; padding-right:120px;"></div>
<div id="text" style="color:white; font-family:sans-serif;
font-size:256px; text-align:right;
line-height:0.8; padding-right:120px;"></div>
</body>
</html>