Jump to content

Creating time sensitive links


Golden Child

Recommended Posts

Hello,

 

I am completely new to php so please forgive me ahead of time. I am trying to create a link button on a website for a client that only directs to a certain external website on certain days and hours. Specifically, this is a web radio button that the client only wants to link to the web radio site when their live broadcast is on the air during certain hours on the weekend (i.e. Sundays 8-10 PM). Any other time, the client wants the web radio button to link to a default page since the web radio station plays unrelated music all other hours of the week. Does anyone know the best way to create such a time sensitive link for a button on a webpage?

 

Thanks.

Link to comment
Share on other sites

The trick is that you do not need to change the link. Instead have the link point to a page that makes the determination as to what page to load. I would probably have the link ALWAYS point to the default page and implement logic at the top of that page to redirect to the radio site at the predetermined hours.

 

$day  = date('N'); //1 (for Monday) through 7 (for Sunday)
$time = date('Gi'); //HoursMinutes (Hours in 24hour format)

//Create condition to check if during radio broadcase
//This example looks for Sat or Sun from 2pm - 4pm
if( ($day==6 || $day==7) && $time>1400 && $time<1600)
{
    //Redirect to radio broadcase
    header("Location: http://domain.com/broadcast/radio.php");
    exit();
}

//Default page content for when broadcast is not avail goes here

Link to comment
Share on other sites

No it would go into PHP code that would come before the output for the default page. I'm not going to try and teach you the basics of PHP in a forum post. If you don't even know how to implement PHP code into a page then you might want to ask someone who does to do this for you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.