0

Just want to ask how to make a countdown timer with alert message every 6 hour and its reset every day. I already make one with var countdowndate but its not what I wanted and I already search in the whole internet and I cant understand anything. so basically what I wanted is I want a timer every 00.00 to 08.00 and after 08.00 its gave an alert "expired" or something like that and after 00.00 in the next day the timer starting again. Thank u

rilude
  • 1
  • 2
    Since nobody will keep a browser tab active and open for several hours, you'd need to set a temporary state persistence (e.g. `localStorage`) that records the first time a user visits the page. In a subsequent visit—or at a regular interval—you'd check how much time has passed since the stored timestamp, and determine whether to expire/reset the timestamp. – Bumhan Yu Apr 19 '22 at 04:09
  • Please show us what you have tried and describe how it doesn’t meet your needs. See https://stackoverflow.com/help/minimal-reproducible-example – A Haworth Apr 19 '22 at 08:12
  • If it's always 08:00, you don't need to store any values. Just a `setInterval()` then compare current time with 08:00 / subtract current time form 08:00 to determine what's left. – freedomn-m Apr 19 '22 at 09:12
  • This may answer (part of) your question: https://stackoverflow.com/q/19004950/2181514 – freedomn-m Apr 19 '22 at 09:13
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 19 '22 at 13:40

0 Answers0