Recreating a Countdown Clock in Hype

Hi,

I had a lot of this code and bits and pieces in other projects. It has not taken to long to put together so here it is.

Time to_countdown timer_v2.hypetemplate.zip (51.2 KB)


Note : the datepicker’s time is returned as ‘00:00:00’ so the count down is midnight when the next day starts.

If you want it work as literal 24hours. i.e from 10pm today to 10pm tomorrow, add this to the setInterval call.

window.d1.setHours(today.getHours(), today.getMinutes(),today.getSeconds());

This gets the time from the today’s date and sets that as the time for the future date.

Shown in use here:

 window.countdownTimer = setInterval(function() {
  runTime = true;
  
  window.d1.setHours(today.getHours(), today.getMinutes(),today.getSeconds());
 
 secondPassed();
 
 }, 1000)
3 Likes