RealTime page redirecting...Need Help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
novasta
Forum Newbie
Posts: 2
Joined: Tue Feb 05, 2008 5:47 am

RealTime page redirecting...Need Help!

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: RealTime page redirecting...Need Help!

Post 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';
}
?>
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: RealTime page redirecting...Need Help!

Post 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...
novasta
Forum Newbie
Posts: 2
Joined: Tue Feb 05, 2008 5:47 am

Re: RealTime page redirecting...Need Help!

Post by novasta »

Thank You very much for your helps.
Post Reply