DaVuLf Posted January 2, 2007 Share Posted January 2, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/32603-php-refresh/ Share on other sites More sharing options...
AV1611 Posted January 2, 2007 Share Posted January 2, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151642 Share on other sites More sharing options...
DaVuLf Posted January 2, 2007 Author Share Posted January 2, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151678 Share on other sites More sharing options...
ober Posted January 2, 2007 Share Posted January 2, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151709 Share on other sites More sharing options...
onlyican Posted January 2, 2007 Share Posted January 2, 2007 Another way to refresh the page is basic HTM<meta http-equiv='refresh' content='60' /> Quote Link to comment https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151732 Share on other sites More sharing options...
DaVuLf Posted January 2, 2007 Author Share Posted January 2, 2007 Yea. I was hoping that I wouldn't have to go that way. I'm currently using a meta refresh at 10seconds. I suppose this is the best way.Thanks for the replies guys. Quote Link to comment https://forums.phpfreaks.com/topic/32603-php-refresh/#findComment-151784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.