Javascript Date Question 3 create auto refresh clock

Introduction

We would like to create a clock for only hours, minutes and seconds.

<!DOCTYPE html> 
<html lang="en"> 
<body> 
    <div id="output"></div> 
    <script> 
       //your code here
    </script> 
</body> 
</html> 


<!DOCTYPE html> 
<html lang="en"> 
<body> 
    <div id="output"></div> 
    <script> 
        function updateTime() { 
            let date = new Date(); 

            let value = date.getHours() + ":" + 
                        date.getMinutes() + ":" + 
                        date.getSeconds(); 

            document.getElementById("output").innerHTML = value; 
        } 

        setInterval(updateTime, 1000); 
    </script> 
</body> 
</html> 



PreviousNext

Related