Hello!
I followed the guide at https://www.sitepoint.com/build-javascript-countdown-timer-no-dependencies/, and have added some intelligence that hides the hours/days when they’re zero.
The last thing I can’t seem to figure out, is how to update the timer once it’s running.
I am sending the timer into an HTML overlay, which is basically just a browser instance. The timer persists and counts down, and I would like to be able to add/remove time from the timer once it’s running. How would I do that?
Thanks!
Hi @joel49, the date object passed to initializeClock()
as endtime
is mutable, so you might still modify it later from outside that function – for instance:
const deadline = new Date(Date.parse(new Date()) + 15 * 24 * 60 * 60 * 1000)
initializeClock('clockdiv', deadline)
// Then later, somewhere else:
deadline.setMinutes(42)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.