Advanced Search

Results 1 to 5 of 5

Thread: date and time redirection

  1. #1
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default date and time redirection

    I have a game script i'm modifying and i'm stuck.I need to redirect based on my servers date and time.I need to restrict player to a certain time frame to play.I can't figure out how to span two days.I need to redirect to the games at Fri 1800 and end Sat 1800.

    I found this on this forum and it's close but doesn't span two dates.

    <?php
    $curTime = date('Gi',time()); //gets current hour [24 hour]
    $hour = date('G');
    $minute = date('i');
    $day = date('w');
    $m = $hour * 60 + $minute; // Minutes since midnight.
    if(
    $day == 6 // Saturday...
    && $m >= 735 // ... after 12:15...
    && $m <= 1035 // ... but before 17:15...
    ) header("Location: saturdayafternoon.php");
    else if(
    $day == 4 // Wednesday...
    && $m >= 1155 // ... after 19:15...
    && $m <= 1335 // ... but before 22:15...
    ) header("Location: http://full path wednesdaynight.php");
    ?>

    Any help would be appreciated.Thanks in advance.

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Hi, What will be easier is if you used a Jscript timer, and have the php code redirect the user when the time is set.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Hmm? Why?

    This is quite possible with PHP.

    PHP Code:
    <?php
    if ((date('G')>=18 && date('w')==5) || (date('G')<=18 && date('w')==6)) {
    $loc "http://...gamepage.php";
    }
    else {
    $loc "http://...other.php"; }
    header("Location: $loc");
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks,i wanted to use php,because my understanding of jscript is it would use the clients computer time and not the servers.Thanks again.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Exactly. JScript is a very different (and almost surely wrong) answer in this case.

    You're welcome.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •