JSFiddle - React, Tailwind, and code Playground

JavaScript

function getDiff(beginningTime) {
    var now = Math.floor(Date.now() / 1000); // get the time now
    var diff = Math.abs(now - beginningTime); // diff in seconds between now and start
    return diff;
  }

  function getTimmer(diff, format){
  	var h = Math.floor(diff / 3600); // diff devided by seconds in an hour
    var m = Math.floor(diff / 60) - (h*60); // get minutes value (quotient of diff minus hours)
    var s = Math.floor(diff % 60); // get seconds value (remainder of diff)
    return { seconds: s, minutes: m, hours: h };
  }
  
	var runClock = (function (){
    var lastDiff = 0;
    return function tick(done, update, countTime, endTime) {
      var diff = getDiff(countTime);
      var timeElapsed = getTimmer(diff);
      if(diff === 0 && lastDiff !== 0){
        return typeof done === 'function' ? done(timeElapsed, diff) : '';
      }
      if(diff !== lastDiff){
        lastDiff = diff;
        return typeof update === 'function' ? update(timeElapsed, diff) : '';
      }
    }
  })();
  
var countDown = Math.floor(Date.now() / 1000)
runClock(null, function(e, r){ console.log( e.seconds );}, countDown);
var t = setInterval(function(){
  runClock(function(){
    console.log('done');
    clearInterval(t);
  },function(timeElapsed, timeRemaining){
    console.log( timeElapsed.seconds );
  }, countDown);
}, 100);