Jump to content

Want to REFRESH site every X minutes until....


cbr_600rr

Recommended Posts

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

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.

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.