Page 1 of 1

RealTime page redirecting...Need Help!

Posted: Tue Feb 05, 2008 5:55 am
by novasta
Hi everybody,
I am new in php and want to ask a question about redirecting.
My pages

index.php
site_morning.php
site_night.php

I only want that for example user came to site at morning.and he will see site_morning.php.And when he came night site_night.php will be on the screen.Is there any method to achieve this?I tried assign variables like between "18:00 and 05:00" redirect to site_night and between "05:00 and 18:00" redirect page to site_morning.php
If you can help me i will be grateful.

Thanks Anyway

Re: RealTime page redirecting...Need Help!

Posted: Tue Feb 05, 2008 11:19 am
by RobertGonzalez

Code: Select all

<?php
// Set the 24 hour numeric representation of the time
$hour = date('G');
 
// Check it against 0600 and 1800 for day time
if ($hour > 6 && $hour < 18) {
  include 'daytimescript.php';
} else {
  include 'nighttimescript.php';
}
?>

Re: RealTime page redirecting...Need Help!

Posted: Tue Feb 05, 2008 12:35 pm
by JAM
Note that this will take use of the server's time, not the users time. If you want the users time, you should look for functions in javascript...

Re: RealTime page redirecting...Need Help!

Posted: Tue Feb 05, 2008 1:22 pm
by novasta
Thank You very much for your helps.