Счетчик на js оставшегося времени для акций

Задача: выводить оставшееся время для акции, с каждой секундой его уменьшать
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$this->setFrameMode(true);
?>
<article class="page-article mb-130"><img class="mb-40" src="<?=$arResult["DETAIL_PICTURE"]["SRC"]?>" alt="1" style="float: left;">
   <div class="title"><span> </span><?=$arResult["NAME"]?></div>
   <?   
   if(isset($arResult["DATE_ACTIVE_FROM"]) && isset($arResult["DATE_ACTIVE_TO"])) {
      $active_from = strtotime($arResult["DATE_ACTIVE_FROM"]);
      $active_to = strtotime($arResult["DATE_ACTIVE_TO"]);
      $current_time = time();

      $days_left = date('d', $active_to) - date('d', $current_time);
   }
   if(isset($arResult["DATE_ACTIVE_FROM"]) && isset($arResult["DATE_ACTIVE_TO"])) {?>
   <p class="subtitle">Период проведения акции: с <?=date('d.m.Y', $active_from)?> до <?=date('d.m.Y', $active_to)?> <br>До конца акции:</p>
   <div class="countdown"></div>
   <div class="time-wrap" id="countdown" data-time="<?=date('Y-m-d', $active_to).'T'.date('h:i', $active_to)?>">
      <div class="time-item">
      <div class="count days"></div><span>Дней</span>
      </div>
      <div class="time-item">
      <div class="count hours"></div><span>Часов</span>
      </div>
      <div class="time-item">
      <div class="count minutes"></div><span>Минут</span>
      </div>
      <div class="time-item">
      <div class="count seconds"></div><span>Секунд</span>
      </div>
   </div>
   <?}?>
   <div class="clear"></div>
   <?=$arResult['DETAIL_TEXT']?>
</article>
<script >
   $(document).ready(function(){
      function SetCountdown(e, t, i, n) {
            var o = document.querySelector(".days"),
                r = document.querySelector(".hours"),
                a = document.querySelector(".minutes"),
                l = document.querySelector(".seconds");
            o.innerHTML = e, r.innerHTML = t, a.innerHTML = i, l.innerHTML = n
        }
      let e = $("#countdown").attr("data-time");
      var t = (new Date(e) - new Date) / 1e3;
        if (t > 0) {
            var i = t / 60,
                n = i / 60,
                o = n / 24;
               i = 60 * (n - Math.floor(n)), o = Math.floor(o), n = Math.floor(n) - 24 * o, t = Math.floor(60 * (i - Math.floor(i))), i = Math.floor(i), SetCountdown(o, n, i, t); 
               let timerId = setInterval((function() {
                0 == t ? 0 == i ? 0 == n ? 0 == o ? showMessage(timerId) : (o--, n = 24, i = 59, t = 59) : (n--, i = 59, t = 59) : (i--, t = 59) : t--, SetCountdown(o, n, i, t)
               }), 1e3);
        }
   });
   
</script>