Simple JavaScript Clock

Simple JavaScript Clock

<SCRIPT Language=”JavaScript”>

<!– hide from old browsers

function jsClock(){

var time = new Date()

var hour = time.getHours()

var minute = time.getMinutes()

var second = time.getSeconds()

var temp = “” + ((hour > 12) ? hour – 12 : hour)

if(hour==0) temp = “12”

if(temp.length==1) temp = ” ” + temp

temp += ((minute < 10) ? “:0” : “:”) + minute

temp += ((second < 10) ? “:0” : “:”) + second

temp += (hour >= 12) ? ” PM” : ” AM”

document.clockForm.digits.value = temp

id = setTimeout(“jsClock()”,1000)

}

//–>

</SCRIPT>

<BODY ONLOAD=”jsClock()”>

<FORM NAME=”clockForm”>

<FONT face=”Courier New,Courier” size=3><B>

<INPUT TYPE=”text” NAME=”digits” SIZE=11 VALUE=”Loading”></B>

</FONT>

</FORM>

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image