The example in this article describes how to simply display time on a web page using js. Share it with everyone for your reference. The details are as follows:
This is a web clock JS code, implemented in pure javascript, which displays hours, minutes and seconds. There are many web time displays and web clocks. This one is really simple. Friends who are good at art can further beautify and improve it on this basis
Simple web clock
<script><br>
window.onload = function ()<br>
{<br>
var oClock = document.getElementById("clock");<br>
var aSpan = oClock.getElementsByTagName("span");<br>
setInterval(getTimes, 1000);<br>
getTimes();<br>
function getTimes ()<br>
{<br>
var oDate = new Date();<br>
var aDate = [oDate.getHours(), oDate.getMinutes(), oDate.getSeconds()];<br>
for (var i in aDate) aSpan[i].innerHTML = format(aDate[i])<br>
}<br>
function format(a)<br>
{<br>
return a.toString().replace(/^(d)$/, "0$1")<br>
}<br>
}<br>
</script>
PointsMinutesSeconds
I hope this article will be helpful to everyone’s JavaScript programming design.