Javascript simple clock.


function setFullHour(h, m, s) {
document.getElementById('hours').value = h;
document.getElementById('minutes').value = m;
document.getElementById('seconds').value = s;
}

function setHours(h) {
document.getElementById('hours').value = h;
}

function setMinutes(m) {
document.getElementById('minutes').value = m;
}

function setSeconds(s) {
document.getElementById('seconds').value = s;
}

var Clock = {
getTime: function() {
var data    = new Date();
var hour    = data.getHours();
var minutes = data.getMinutes();
var seconds = data.getSeconds();
//setHours(hour);
//setMinutes(minutes);
//setSeconds(seconds);
//OR
setFullHour(hour, minutes, seconds);
}
};

setInterval(clock.getTime(), 1000);
clock.getTime()

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s