PrimitiveType

JavaScript digital clock

Here's a very basic clock written in JavaScript. Note that the time is based on the client's system time, so if that is wrong, this clock will be wrong too.

00:00:00

The code:

<p id="theTimer">00:00:00</p>
<script type="text/javascript">
<!--
window.setTimeout("updateTime()", 0);// start immediately
window.setInterval("updateTime()", 1000);// update every second
function updateTime() {
    document.getElementById("theTimer").firstChild.nodeValue =
    new Date().toTimeString().substring(0, 8);
}
//-->
</script>