title: Countdown.js reset time
body: <p>Hello I try to start and reset the counter from countdown.js with pressing one button.</p>
  
  <p>When I press the button a second time it starts a new timer and jump between the old timer and new one.</p>
  
  <p>I would like to clear the timer / reset the timer and start then.</p>
  
  <p>I tried using clearInterval(timeinterval); as a single button and it's not working either.</p>
  
  <pre><code>$("#reset").click(function () {
      //timer = new Countdown();
      clearInterval(timeinterval);
  });
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    
  $("#trigger-start").click(function () {
  
      var check = true;
  
      function getTimeRemaining(endtime) {
          var t = Date.parse(endtime) - Date.parse(new Date());
          var seconds = Math.floor((t / 1000) % 60);
          var minutes = Math.floor((t / 1000 / 60) % 60);
          var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
          var days = Math.floor(t / (1000 * 60 * 60 * 24));
          return {
              'total': t,
              'days': days,
              'hours': hours,
              'minutes': minutes,
              'seconds': seconds
          };
      }
  
      function initializeClock(id, endtime) {
          var clock = document.getElementById(id);
          var daysSpan = clock.querySelector('.days');
          var hoursSpan = clock.querySelector('.hours');
          var minutesSpan = clock.querySelector('.minutes');
          var secondsSpan = clock.querySelector('.seconds');
  
          function updateClock() {
              var t = getTimeRemaining(endtime);
  
              daysSpan.innerHTML = t.days;
              hoursSpan.innerHTML = ('0' + t.hours).slice(-2);
              minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
              secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);
  
              if (t.total &lt;= 0) {
                  clearInterval(timeinterval);
              }
          }
  
          updateClock();
          var timeinterval = setInterval(updateClock, 1000);
      }
  
      var deadline = new Date(Date.parse(new Date()) + 20 * 24 * 60 * 60 * 1000);
      initializeClock('clockdiv', deadline);
  
      $(".button-content-start").toggleClass("stop");
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="clock row m-b-xl"&gt;
  &lt;div id="clockdiv"&gt;
      &lt;div class="panel-solid-info widget-mini col-xs-3" id="canvas_days" style="padding:0 1px !important;"&gt;
          &lt;div class="panel-body"&gt;
              &lt;span class="total text-center val days"&gt;&lt;span id="countdown-tage"&gt;&lt;/span&gt;&lt;/span&gt;
              &lt;span class="title text-center type-days type-time"&gt;Tage&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="panel-solid-info widget-mini col-xs-3" id="canvas_hours" style="padding:0 1px !important;"&gt;
          &lt;div class="panel-body"&gt;
              &lt;span class="total text-center val hours"&gt;&lt;span id="countdown-stunden"&gt;&lt;/span&gt;&lt;/span&gt;
              &lt;span class="title text-center type-hours type-time"&gt;Stunden&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="panel-solid-info widget-mini col-xs-3" id="canvas_minutes" style="padding:0 1px !important;"&gt;
          &lt;div class="panel-body"&gt;
              &lt;span class="total text-center val minutes"&gt;&lt;span id="countdown-minuten"&gt;&lt;/span&gt;&lt;/span&gt;
              &lt;span class="title text-center type-minutes type-time"&gt;Minuten&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="panel-solid-info widget-mini col-xs-3" id="canvas_minutes" style="padding:0 1px !important;"&gt;
          &lt;div class="panel-body"&gt;
              &lt;span class="total text-center val seconds"&gt;&lt;span id="countdown-sekunden"&gt;&lt;/span&gt;&lt;/span&gt;
              &lt;span class="title text-center type-seconds type-time"&gt;Sekunden&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;button class="btn btn-success btn-lg col-xs-12 col-sm-6 col-sm-offset-3" data-toggle="modal" data-target="#formModal"
      id="trigger-start"&gt;&lt;i class="button-content-start"&gt;Start&lt;/i&gt;&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>thanks in advance</p>