I am try to get the current server time into javascript clock where the clock starts ticking up to show the current running time but can't seem to get it to work. The code I am using so far is: function show2(){ if (!document.all) return var Digital=new Date("<? echo $mytime; ?>") var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds() var dn="AM" if (hours>12){ dn="PM" hours=hours-12 } if (hours==0) hours=12 if (minutes<=9) minutes="0"+minutes if (seconds<=9) seconds="0"+seconds var ctime=hours+":"+minutes+":"+seconds+" "+dn tick2.innerHTML="<b style='font-size:22;color:blue;'>"+ctime+"</b>" setTimeout("show2()",1000) } window.onload=show2 Code (markup): Anyone have any idea as to what I am doing wrong or have a better solution to get it to work? Thanks in advance.
<form name="Tick"> <input type="text" size="11" name="Clock"> </form> <script> function show(){ var Digital=new Date(<?php $mytime; ?>) var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds() var dn="AM" if (hours>12){ dn="PM" hours=hours-12 } if (hours==0) hours=12 if (minutes<=9) minutes="0"+minutes if (seconds<=9) seconds="0"+seconds document.Tick.Clock.value=hours+":"+minutes+":" +seconds+" "+dn setTimeout("show()",1000) } show() </script> Please try with this script The above script you are using is not defined span "tick2"