Search code examples
javascriptjquerycounterflipclock

Countdown flipclock and reset after counting to zero


http://flipclockjs.com/

I need a counter which counts down to zero from a certain time (for example 2 hours). After those two hours the timer needs to reset and starts again.

How can I do this? I can't find anything about it in their docs.

What I got now:

var clock = $('.your-clock').FlipClock({
  countdown : true,
});

Solution

  • Try this one:

    var clock = $('.your-clock').FlipClock({
      countdown : true,
    });
    clock.setTime(10);
    clock.start();
    setTimeout(function(){ 
      checktime();
    }, 1000);
    
    function checktime(){
      t = clock.getTime();
      if(t<=0){
        clock.setTime(10);
        clock.start();
      }
      setTimeout(function(){ 
        checktime();
      }, 1000);
    }