'how do i set countdown timer in node js and render it?
I am currently developing an auction website using Nodejs and react. For each bidding product, I want to display a countdown timer indicating the end of auction. I could not implement it in react because the timer just resets every time the user refreshes the website, or visits another page. I would like to count down the time for each product in backend(Nodejs) and somehow render it in react. How will that be possible?
Solution 1:[1]
the date time of your auction start should come from the DB and then the front end timer should start from there, rather than giving the authroization of the timer start time to front end
so you have the acution start time and calculate the timer based on that.
Let's say the auction start time is start_time
and let's say the current time is current_time
so current_time - start_time gives you how many seconds/minute has passed till the auction started.
and let's say the auction time is auction_time. So basically you could simply write auction_time - (current_time - start_time) to give you a counter value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
