window.οnlοad=function(){ setTime(); setInterval('setTime()',1000); } function checkTime(n){ if(n<10){ return "0" +n; }else{ return ""+n; } } function setTime(){ var date=new Date(); var h=checkTime(date.getHours()); var m=checkTime(date.getMinutes()); var s=checkTime(date.getSeconds()); var time=document.getElementById('time'); time.innerHTML=h+":"+m+":"+s; }