title: Javascript time counter running backwards
body: <p>Hi guys I have a time counter I want to count from 15 to 0. but with the current version it counts from 0 to 15. it should be running backwards. any suggestions?</p>
  
  <pre><code>  // Set the minutes
    var countDownMins = new Date().getMinutes() + 15;
  
    // Update the count down every 1 second
    var x = setInterval(function() {
  
      // Get current time
      var now = new Date().getTime();
  
      var distance =  now + countDownMins;
  
      mins = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
      secs = Math.floor((distance % (1000 * 60)) / 1000);        
  
      // Output the results
      document.getElementById("minutes").innerHTML = mins;
      document.getElementById("seconds").innerHTML = secs;
  
      if (mins &lt; 0) {
        clearInterval(x);
      }
  
    }, 1000);
  </code></pre>