1 minutes 30 second countdown timer javascript

I have the code but it’s for 2 minutes timer and i need it to modify to 1 minutes 30 seconds timer.

I have tried but fails to start timer from 1:30.

As i’m beginner in this line and want to learn how to do that.

here it’s the code

<div id=timer></div>
<script type="text/javascript">
  var timeoutHandle;

  function countdown(minutes, seconds) {
    var seconds = 60;
    var mins = minutes

    function tick() {
      var counter = document.getElementById("timer");
      var current_minutes = mins - 1
      seconds--;
      counter.innerHTML =
        current_minutes.toString() + ":" + (seconds < 10 ? "0" : "") + String(seconds);
      if (seconds > 0) {
        timeoutHandle = setTimeout(tick, 1000);
      } else {

        if (mins > 1) {

          // countdown(mins-1);   never reach “00″ issue solved:Contributed by Victor Streithorst
          setTimeout(function() {
            countdown(mins - 1);
          }, 1000);

        }
      }
    }
    tick();
  }

  countdown(2);
</script>

45 thoughts on “1 minutes 30 second countdown timer javascript”

Leave a Comment