I had a simple idea to create a clock that only shows the time, not the date. The issue I encountered with the code provided is that it displays the time when the .html file is initially opened.
<body onload="showTime()">
<p id="time"></p>
<script>
var seconds;
var minutes;
var hours;
var currentTime;
function showTime() {
seconds = getSeconds();
minutes = getMinutes();
hours = getHours();
document.getElementById("demo").innerHTML =
hours +":"+ minutes +":"+ seconds;
}
Is there any way for me to make it update automatically every second? Appreciate any help!