DEV Community

Discussion on: How to Create a Simple React Countdown Timer

Collapse
 
seanmclem profile image
Seanmclem

I had good success creating a timer by storing the current datetime when starting the timer, and then on every interval getting the new current datetime again and doing the math to find the difference. If any computation takes longer than it should - it doesn't matter. The date time is always valid

Collapse
 
zhiyueyi profile image
Zhiyue Yi

Hey Sean! Interesting thoughts! I tried your approach, and it also works!

Collapse
 
seanmclem profile image
Seanmclem

Thanks! That's awesome