CLOCK
1 month ago in Plain Text
function tick() 
{
var hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;

today = new Date();

intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();

if (intHours == 0)
{
hours = "24:";
ap = "AM";
}
else if (intHours < 24)
{
hours = intHours+":";
ap = "AM";
}
else if (intHours == 24)
{
hours = "24:";
ap = "PM";
}
else
{
intHours = intHours - 24
hours = intHours + ":";
ap = "PM";
}

if (intMinutes < 10)
{
minutes = "0"+intMinutes+":";
}
else
{
minutes = intMinutes+":";
}

if (intSeconds < 10)
{
seconds = "0"+intSeconds+" ";
}
else
{
seconds = intSeconds+" ";
}

timeString = hours+minutes+seconds+ap;

Clock.innerHTML = timeString;

window.setTimeout("tick();", 100);
}

window.onload = tick;
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