Working HTML clock with no dependencies

Published on August 17th, 2019

html icon

This is also one of those fun and not the most practical articles. But it can work. Hence “Working” in title. You don’t get fancy options you’d find in some JavaScript library, but at least you don’t send giant JavaScript bundle just to show clock. Looking at you devs who use Moment.js just to display basic clock.

<body
  onload="setInterval(()=>document.getElementById('clock').innerHTML=new Date().toGMTString().slice(17,25))"
>
  <div id="clock"></div>
</body>

You can visit cool demo I’ve made for this article.