How to create a clock with JavaScript or PHP

View:
2:37:09 Monday


Answer 1, authority 100%

<!------------------------  -------------------------------->
<script type="text/javascript"> 
var d=document
var NN=d.layers?true:(window.opera&&!d.createComment)?true:false
function showTime(){
 var tmN=new Date()
 var dH=''+tmN.getHours();dH=dH.length<2?'0'+dH:dH
 var dM=''+tmN.getMinutes();dM=dM.length<2?'0'+dM:dM
 var dS=''+tmN.getSeconds();dS=dS.length<2?'0'+dS:dS
 var tmp=dH+':'+dM+':'+dS
 if(NN)d.F.chas.value=tmp;else d.getElementById('tm').innerHTML=tmp
 var t=setTimeout('showTime()',1000)
}
</script>
<div id=tm><form name="F"><input type="button" name="chas" value="XX:XX:XX"></form></div>
<script type="text/javascript">showTime()</script>
<!------------------------   -------------------------------->

Source.