Jump to content

PHP Refresh


DaVuLf

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.