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

Link to comment
Share on other sites

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.

Link to comment
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.