PDA

View Full Version : JS Clock



LearningCoder
01-12-2011, 12:00 AM
Hey, I have a JS clock in my webpage.

I was wondering how to align it to the bottom+middle. Do I use the align and valign attributes?

I'm very new to JS so bear with me!

Thank you all in advance for any guidance!:)

cindylou
01-12-2011, 03:03 AM
hi there..

here's a script a can share with you...


function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
// add a zero in front of numbers<10
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML = h + ":" + m + ":" + s;
t = setTimeout('startTime()', 500);
}

function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}


so the clock here is aligned on the right side...you can change if you want it somewhere else...:)