Web Page Redirect Based on Server Time of Day

Discussion in 'Programming' started by voicetoons, Sep 16, 2011.

  1. #1
    Hi Gang,Hey does anyone know if there is a simple free script / code which allows us to redirect a web site visitor to another page based on the time of day? I've found many for day of week, etc but not by our server time. We are a live character calling service and wish to redirect users to our closed page at the end of our business day as to stop orders from coming in for the day if any.Any help or script is appreciated.VoiceTOONS
     
    voicetoons, Sep 16, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Something like
    
    <?php
    // set the default timezone to use.
    date_default_timezone_set('America/New_York');
    
    $hour = date('G');
    
    //if after 1700 (5PM), send the user to the other page
    if($hour > 16) {
        header('location: http://www.oursite.com/ourclosedpage.html');
    }
    ?>
    
    PHP:
    Note - if you don't set the time zone properly, you'll have to use whatever time your server is set to. IOW, if you want 6PM to be the trigger time, and your server is set to 3 hours later than your local time, you'll have to use 3, not 6, as the trigger.
     
    Rukbat, Sep 16, 2011 IP
  3. voicetoons

    voicetoons Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you. Does this go below the or ? Very much appreciated. We will give it a try.V
     
    voicetoons, Sep 19, 2011 IP
  4. voicetoons

    voicetoons Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you. We meant does this go in the head or body tag? Much appreciated again.
     
    voicetoons, Sep 19, 2011 IP