cbr_600rr Posted November 14, 2009 Share Posted November 14, 2009 Hi everyone, I have a block of code, or I guess an entire php page that I would like to refresh itself. I have found several ways to refresh a page every couple of minutes, but how would I go about doing so for a given period of time. either... 1.) Refresh page every 5 minutes for 2 hours, or.. 2.) Refresh page every 5 minutes until 3:00PM (Central time) Im more interested in the 2nd option, however either would be useful. thanks Quote Link to comment https://forums.phpfreaks.com/topic/181525-want-to-refresh-site-every-x-minutes-until/ Share on other sites More sharing options...
ram4nd Posted November 14, 2009 Share Posted November 14, 2009 http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm Quote Link to comment https://forums.phpfreaks.com/topic/181525-want-to-refresh-site-every-x-minutes-until/#findComment-957564 Share on other sites More sharing options...
cbr_600rr Posted November 14, 2009 Author Share Posted November 14, 2009 I know how to do basic refreshes, I am trying to figure out how I can limit it to do so for either X amount of time, or until a certain time of day. Quote Link to comment https://forums.phpfreaks.com/topic/181525-want-to-refresh-site-every-x-minutes-until/#findComment-957572 Share on other sites More sharing options...
ram4nd Posted November 14, 2009 Share Posted November 14, 2009 well use date funcion or something Quote Link to comment https://forums.phpfreaks.com/topic/181525-want-to-refresh-site-every-x-minutes-until/#findComment-957575 Share on other sites More sharing options...
Alex Posted November 14, 2009 Share Posted November 14, 2009 First 1) You could use PHP sessions to store the time of the first refresh, then run a conditional to see if it has been 2 hours yet. For 2) You could do something similar, just no sessions required, just check the time of day. // 1) session_start(); if(!isset($_SESSION['first'])) $_SESSION['first'] = time(); if($_SESSION['first'] + 60*60*2 < time()) // Some refresh method // 2) date_default_timezone_set('...whatever timezone you want this based on'); if(intval(date('G')) < 15) // Some refresh method You might need to use sessions on the second way depending on how you want it to work. Quote Link to comment https://forums.phpfreaks.com/topic/181525-want-to-refresh-site-every-x-minutes-until/#findComment-957577 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.