title: Problem with subtracting dates in real time with use setinterval
body: <p>In this script I use some functions and xDate library for create true format dates. I am trying to make a small script, that show  the difference between two dates with a times in real time, but I do not see an error in the code that does not allow this to be done. Where is the error?</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>jQuery(window).on("load", function() {
    function parseISOLocal(s) {
      // Split string into its parts
      var b = s.split(/\D/);
      // Create and return a date object
      return new Date(b[0], b[1] - 1, b[2], b[3], b[4], b[5]);
    }
  
    // Convert a millisecond value to days, hours, minutes and seconds
    function formatDHMS(ms) {
      // Helper to add 's' to a number if other than 1
      function addS(n) {
        return n == 1 ? '' : 's';
      }
  
      var d = ms / 8.64e7 | 0;
      var h = (ms % 8.64e7) / 3.6e6 | 0;
      var m = (ms % 3.6e6) / 6e4 | 0;
      var s = (ms % 6e4) / 1e3 | 0;
  
      dd = (d != 0) ? d + ' day' + addS(d) + ', ' : "";
      hh = (h != 0) ? h + ' hours' + addS(h) + ', ' : "";
      mm = (m != 0) ? m + ' minute' + addS(m) + ', ' : "";
      ss = (s != 0) ? s + ' second' + addS(s) + ' ' : "";
  
      return ((d + h + m + s) &gt; 0) ? dd + hh + mm + ss : "Time is over";
    }
  
    Date.prototype.addDays = function(days) {
      var date = new Date(this.valueOf());
      date.setDate(date.getDate() + days);
      return date;
    }
  
    var date = new Date("2020-05-01 12:24:23");
  
    var d1 = new XDate(date.addDays(2));
    future_time = d1.toString("yyyy-MM-dd HH:mm:ss");
    var d = new XDate();
  
    current_time = d.toString("yyyy-MM-dd HH:mm:ss");
  
    var someDate = new Date();
    someDate.setDate(someDate.getDate() + 15); //number  of days to add, e.x. 15 days
    var dateFormated = someDate.toISOString().substr(0, 10);
    console.log(dateFormated);
  
    function Repeat() {
  
      setInterval(function() {
  
        current_time = d.toString("yyyy-MM-dd HH:mm:ss");
  
        $('#timeForSign').html(formatDHMS(parseISOLocal(future_time) - parseISOLocal(current_time)));
      }, 100);
    }
  
    setTimeout(Repeat, 500);
  
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://www.outsourcer.info/xdate.js"&gt;&lt;/script&gt;
  &lt;div id="timeForSign"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>