title: How to show custom time In dom using new Date() object in JavaScript?
body: <p>I am a beginner in javascript, what I am trying to do is using <code>new Date()</code> object and show a custom hour, minutes and seconds but in <code>countDown()</code> function I have to pass full date and it starts counting from that date.</p>
  <p>My goal is for example I give number 1 as (hour) and then it should start counting down.</p>
  <p>I would appreciate it if someone can help me</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Timer {
    constructor(holder) {
  
      var controller = {
        holder: holder,
        end: null,
        intervalID: 0,
        display: function () {
          var _second = 1000;
          var _minute = _second * 60;
          var _hour = _minute * 60;
          var _day = _hour * 24;
  
          var msg = "";
  
          var now = new Date();
  
          var distance = controller.end - now;
          if (distance &lt; 0) {
  
            clearInterval(controller.intervalID);
            controller.holder.innerHTML = 'EXPIRED!';
  
            return;
          }
  
          var days = Math.floor(distance / _day);
          var hours = Math.floor((distance % _day) / _hour);
          var minutes = Math.floor((distance % _hour) / _minute);
          var seconds = Math.floor((distance % _minute) / _second);
          controller.holder.innerHTML = hours + ' Hours | ' + minutes + ' Minutes | ' + seconds + ' Seconds ';
  
        }
      };
  
      this.countDown = function (end) {
        controller.end = end;
        controller.intervalID = setInterval(controller.display, 1000);
      };
    }
  }
  
  var timers = {};
  
  timers.one = new Timer(document.getElementById("one"));
  timers.two = new Timer(document.getElementById("two"));
  timers.three = new Timer(document.getElementById("three"));
  
  
  //Hier I should be able to give a number
  timers.one.countDown(new Date("Feb 30, 2022 15:37:25"));
  timers.two.countDown(new Date(2022, 10, 29, 12, 40, 40));
  timers.three.countDown(new Date(2022, 11, 9, 13, 45, 30));</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div id="one"&gt;&lt;/div&gt;
   &lt;div id="two"&gt;&lt;/div&gt;
   &lt;div id="three"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>