JavaScript Clock
If you are searching for JavaScript Clock to display on your website, here is the end of your search.
Following JS script will fulfill your need.
<HTML>
<SCRIPT>
var now;
function render24FormatTime() {
if (document.theForm.show24Hrs[0].checked) {
return true;
}
return false;
}
function renderTheHours(theHour) {
if (render24FormatTime() || (theHour > 0 && theHour < 13)) { return (theHour); } if (theHour == 0) { return (12); } return (theHour - 12); } function renderZeroFilled(inValue) { if (inValue > 9) {
return ":" + inValue;
}
return ":0" + inValue;
}
function renderAmPm() {
if (render24FormatTime()) {
return ("");
}
if (now.getHours() < 12) {
return (" am");
}
return (" pm");
}
function renderTheTime() {
now = new Date();
document.theForm.renderTime.value =
renderTheHours(now.getHours()) +
renderZeroFilled(now.getMinutes()) +
renderZeroFilled(now.getSeconds()) +
renderAmPm();
setTimeout("renderTheTime()", 1000);
}
</SCRIPT>
<BODY onLoad="renderTheTime();">
<FORM NAME="theForm">
<INPUT TYPE="TEXT" NAME="renderTime">
Display 24 Hrs Format Time?
<INPUT TYPE="RADIO" NAME="show24Hrs" CHECKED />Yes
<INPUT TYPE="RADIO" NAME="show24Hrs" />No
</FORM>
</BODY>
</HTML>