Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,700 Times in 2,676 Posts
    I am happy to help, but I am afraid that I do not see why the counter does not reset on page refresh.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  2. #17
    Regular Coder
    Join Date
    Oct 2014
    Thanked 84 Times in 83 Posts
    Sorry I couldn't have been here to walk you through this (away from the Internet all weekend) but it looks like you were able to figure it out yourself.

    You can do this with pure JavaScript it's just a matter of hard-coding specific times into the page's source code. If it's always every 43 minutes than all you really need to do is hard-code the 33 times per day that should be "target" times. I would just slap a 21-minute gap between the last and first target times so that it's always going off at the exact same times every day—otherwise this becomes a really annoying problem to solve. (Also you'd want to figure out how long the "Expired" message should show—just for 1 minute? or is there a specific gap between countdowns?)

    Anyway I digress, it looks like you have what you want. Thanks for posting the code you used for future reference.

    Quote Originally Posted by Philip M View Post
    I am happy to help, but I am afraid that I do not see why the counter does not reset on page refresh.
    It looks like it's just counting down to Midnight of whatever the current day is. If you use a specific reference date in the future, the counter won't technically "reset" when you refresh the page since it will always be showing a number of days/hours/minutes/seconds left until that time is reached and is re-calculated on every loop. The original code i posted seems way easier to understand than what was eventually used but if it works ... I guess that's good enough.
    Last edited by sagebrushfire; 05-22-2017 at 11:30 PM.
    I almost always format my code examples with [php][/php] tags because it looks nicer than the regular [code] tag. That does not mean the code example is in PHP.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts