Cel mai simplu ceas.
Cod
<div id="idspclock1" style="text-align:center;"></div>
<script type="text/javascript">
$spclock1={
tmr: 0,
dubnums: function(i){
if(i.length==1) return '0'+i; else return i;
},
gettime: function(){
tm=new Date();
var h=new String(tm.getHours());
var m=new String(tm.getMinutes());
var s=new String(tm.getSeconds());
var st=this.dubnums(h);
st+=':'+this.dubnums(m);
st+=':'+this.dubnums(s);
return st;
},
timeit: function(){
window.clearTimeout(this.tmr);
document.getElementById('idspclock1').innerHTML=this.gettime();
this.tmr=window.setTimeout('$spclock1.timeit();',1000);
},
ready: function(){
this.timeit();
}
}
$spclock1.ready();
</script>
Rezultatul: