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