Answers for "live clock javascript"

0

live clock javascript

//javascript
var span = document.getElementById('clock');

function time() {
  var d = new Date();
  var s = d.getSeconds();
  var m = d.getMinutes();
  var h = d.getHours();
  span.textContent = 
    ("0" + h).substr(-2) + ":" + ("0" + m).substr(-2) + ":" + ("0" + s).substr(-2);
}

setInterval(time, 1000);

//html
<span id="clock"></span>
Posted by: Guest on August-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language