Jump to content

Recommended Posts

Hey there. I have a script that keeps track of minutes, and without being too processor intensive (ie checking every 60 seconds) I want my page to refresh as soon as the minute changes. Is there any way to accomplish this?

I know that this is quite vague, although I'm not sure how better to explain myself. Currently I'm using a meta refresh every 10 seconds or so, but this has the opportunity to miss the minute mark. Would there be any way to do so?

If you need any of my code or whatnot, please let me know.

Thanks,
DaVulF
Link to comment
https://forums.phpfreaks.com/topic/32603-php-refresh/
Share on other sites

Don't know if this will help you...
<script language="Javascript">
setInterval("settime()", 1000);
function settime () {
  var curtime = new Date();
  var curhour = curtime.getHours();
  var curmin = curtime.getMinutes();
  var cursec = curtime.getSeconds();
  var time = "";
  if(curhour == 0) curhour = 12;
  time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
        (curmin < 10 ? "0" : "") + curmin + ":" +
        (cursec < 10 ? "0" : "") + cursec + " " +
        (curhour > 12 ? "PM" : "AM");
  document.date.clock.value = time;
}
</script>
Link to comment
https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151642
Share on other sites

Thats essentially what I have written out in PHP, but that is not what is currently at issue.

Right now I have access to a variable that I can run a modular on to determine if it is divisible by 60, and if so, then to refresh the page (which would refresh on the minute, every minute). The only question is how to run this loop without locking up my SQL, since the times are both taken from my database. Then the question would be how to refresh the darned HTML once the condition is satisfied.

I will keep giving it a shot :).

Thanks for the reply though.
Link to comment
https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151678
Share on other sites

You're not going to be able to strictly do this with PHP.  You'll need something on the front end (JS) to actually do the refresh.  And I really doubt you're ever going to hit it exactly on the 60 second mark unless your pegging the backend every second (bad idea).  I'd suggest a 10 second window.
Link to comment
https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151709
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.