1//javascript
2var span = document.getElementById('clock');
3
4function time() {
5 var d = new Date();
6 var s = d.getSeconds();
7 var m = d.getMinutes();
8 var h = d.getHours();
9 span.textContent =
10 ("0" + h).substr(-2) + ":" + ("0" + m).substr(-2) + ":" + ("0" + s).substr(-2);
11}
12
13setInterval(time, 1000);
14
15//html
16<span id="clock"></span>