Is it possible to get a constantly progressing progress bar? I want to make a countdown to a date. My date is 1/1/22 but I don’t know how to get the progress bar to constantly update.
You already have some setup + some code? Or do you expect it to be done for you?
Show the setup you already have, show your already generated project-parts.
What did you already have tried, to accomplish your wished functionality?
I’ll give you some hints:
- you will need 3 dates: the start date, the end date (1/1/22) and, every day, today’s date
- the progress bar needs a target (difference between start and end date, always the same)
- it also needs a progress value (.value), which is the difference between todays date and start date
We assume that you don’t want to update this thing every second (pointless), just every day on page load.
Below my function to calculate the amount of days between to dates:
function datediff(first, second) {
return Math.abs(Math.round((second - first) / (1000 * 60 * 60 * 24)));
}
Good luck.