JSFiddle - React, Tailwind, and code Playground

by Johan Muller

HTML

<div class="e">

</div>

JavaScript

var offset = 2;
      function updateClock() {
           // Gets the current time
           var now = new Date();

           // Get the hours, minutes and seconds from the current time
           var hours = +offset + now.getUTCHours();
           if (hours >= 24) hours -= 24;
           var minutes = now.getUTCMinutes();
           var seconds = now.getUTCSeconds();

           // Format hours, minutes and seconds
           if (hours < 10) {
               hours = "0" + hours;
           }
           if (minutes < 10) {
               minutes = "0" + minutes;
           }
           if (seconds < 10) {
               seconds = "0" + seconds;
           }

           $('.e').html(hours + ':' + minutes + ':' + seconds);
       }

       setInterval(updateClock, 200);