JSFiddle - React, Tailwind, and code Playground

by brigand

HTML

<div id="out"></div>

JavaScript

const end = new Date('2019-01-20T09:34:19.052Z');

const tick = () => {
  const now = new Date();

  let s = '';

  const diffHours = end.getUTCHours() - now.getUTCHours();
  s += (diffHours + 24) % 24 + 'h ';

  const diffMin = end.getUTCMinutes() - now.getUTCMinutes();
  s += (diffMin + 60) % 60 + 'm ';

  const diffSec = end.getUTCSeconds() - now.getUTCSeconds();
  s += (diffSec + 60) % 60 + 's ';


  out.textContent = s
  requestAnimationFrame(tick)
}

tick();