JavaScript implements simple clock instance code


<html>
<head>
<title>JS Implement a simple clock </title>
<script>
    function displayTime() {
        document.getElementById("time").innerHTML = new Date().toTimeString();
    }

    setInterval(displayTime,1000);      //The displayTime function is called every 1 second
</script>
</head>
<body>
    <p id="time"></p>
</body>
</html>