Page 1 of 1

Automatically switching index page?

Posted: Wed Jul 19, 2006 2:13 pm
by Aegiss
Hey guys. I was wondering if there's a way to automatically change my main page on a certain time in the week. See I have a site for a radio show that i do every sunday night from 9 to midnight and i want to switch to a page that has a big blinking LISTEN NOW link on the main page when it's 9 p.m. and then back to normal at midnight. Is there any way to do a little time-based switcharoo here with php? I'm familiar with cron jobs if that would help. Thanks!

Re: Automatically switching index page?

Posted: Wed Jul 19, 2006 2:56 pm
by aerodromoi
Aegiss wrote:Hey guys. I was wondering if there's a way to automatically change my main page on a certain time in the week. See I have a site for a radio show that i do every sunday night from 9 to midnight and i want to switch to a page that has a big blinking LISTEN NOW link on the main page when it's 9 p.m. and then back to normal at midnight. Is there any way to do a little time-based switcharoo here with php? I'm familiar with cron jobs if that would help. Thanks!

Code: Select all

<?php
if ((date("G") >= 21) && (date("w") == 0)){
  header("Location: http://www.inexistantdomain.net/");
  exit;
}
?>
This should redirect you to another page on sundays between 9pm and 11:59pm.
However, don't send any headers before this snippet is called!

Posted: Wed Jul 19, 2006 3:55 pm
by Aegiss
ok i'll try that. it's 9-12 central time though. Is there a way to set that in the code? just wondering if someone on the west coast would get something different

Posted: Wed Jul 19, 2006 3:56 pm
by Luke
php is going to pull the time from your server, so it doens't matter where the user is

Posted: Wed Jul 19, 2006 4:01 pm
by Aegiss
hmm does the location of my server matter then? im not sure where its located

Posted: Wed Jul 19, 2006 4:02 pm
by hawleyjr
Location doesn't matter at all. It only matters what time your server thinks it is :)

Posted: Wed Jul 19, 2006 4:05 pm
by Aegiss
hehe ok and how can i determine what it's thinking?

Posted: Wed Jul 19, 2006 4:19 pm
by daedalus__

Code: Select all

echo date('O');
Compare that timezome to your timezone and then +/- hours from the date you display.

Posted: Wed Jul 19, 2006 4:22 pm
by RobertGonzalez
Make sure you account for the server location. I had a server located in Florida though my target audience was in California. It took me a few days before I realized I had to adjust the date/time display for three hours back.

Posted: Wed Jul 19, 2006 4:33 pm
by Aegiss
ah good deal. turns out its eastern. good to know :)

Posted: Wed Jul 19, 2006 4:37 pm
by RobertGonzalez
BTW, do you need an entire redirect or can you just throw some time related content?

Posted: Wed Jul 19, 2006 4:47 pm
by Aegiss
no i think redirect would be best. It works fine like that.