summaryrefslogtreecommitdiff
path: root/tempo.js
blob: db8c03943f36a752c8f5168becf516a7eb8388a2 (plain) (blame)
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
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

function padTime(x) {
	if(x < 10) {
		return "0" + x;
	} else {
		return x;
	}
}

function updateTime() {
	var date = new Date();

	var h = date.getHours();
	var m = date.getMinutes();
	var s = date.getSeconds();

	var dd = date.getDate();
	var dm = date.getMonth();
	var dy = date.getFullYear();

	var str_t = padTime(h) + ":" + padTime(m) + ":" + padTime(s);
	var str_d = dd + " " + months[dm] + " " + dy;

	document.getElementById("timeval").innerHTML = str_t;
	document.getElementById("dateval").innerHTML = str_d;
}

function startTempo() {
	updateTime();

	setInterval(updateTime, 1000);
}

window.onload = startTempo;