Jump to content

Time delayed content


Kibit

Recommended Posts

I want to be able to display basic html formatted text at certain times of certain days.

 

This will be displaying currently playing information for a radio website.

 

So what I need is the ability to display..

 

say..

 

 

 

Monday @ 8pm "DJ Bla Bla"

Monday @ 9pm "DJ XYZ"

 

I'm hopeing to simply use the server time (+6hrs) to achive this and also that its written in something like php/html (anything that does not require java or any other non standard plugin to be installed)

 

Can anyone help with this?

 

I've been given this reply to start with from a friend of mine...

 

$now = time();

if($now > mktime(8,0,0) || $now < mktime(9,0,0)){
  include('8til9dj.php');
}
elseif($now > mktime(9,0,0) || $now < mktime(10,0,0){
  include('9til10dj.php');
}

I would do that to start, then I would realise that my logic was flawed and retinker it. That's the approach I would take though, so you are saying, get the current time, then if it's between these values then do this, otherwise if it's between these values do that etc.

 

I'm sure someone will give you a better answer :)

 

Don't forget that you can

$time = time();
if($time >= strtotime('2008-04-23 19:00:00')){ echo 'now is in the future!'; }

 

 

But how do I include day of the week? I dont really need the full date just day of the week and time.

Link to comment
Share on other sites

well there are probably numerous ways to do this. Based on a seven day week and 24 hours in the day you have 168 possibilities.

 

You could use switch statments etc; but the rough lazy way is to:

 

1. create a separate file for each distinct text (need 168 files)

 

2. name each file for the time slot it will display. ie 0100 is for sunday morning from midnight to 1AM, 0114 would be Sunday afternoon from 2PM to 2:59 etc etc

 

3. then use the following to call the appropriate file

 

 

 

 

$now = date('H',time());
$whatday = date(',D',time());

$file = $whatday . $now . "php"

 

Link to comment
Share on other sites

Thanks for the help.

 

Gone with this...

 

<html>
<head><title>Test PHP Script</title></head>
<body>

<?php
$shows['Thu_14:00']['title']="8pm till 9pm Show";
$shows['Thu_15:00']['title']="9pm till 10pm Show";
$shows['Thu_16:00']['title']="10pm till 11pm Show";
$shows['Thu_17:00']['title']="11pm till 12am Show";
//etc 

echo $shows[date("D_H:00")]['title'];  

?>
</body>
</html>

 

Which is working well, but! Is there anyway to do an else echo to echo a $shows['Anytime I've not specified']['title']="Now playing: Auto Pilot Next Live show Thursday 8pm";

EDIT: BTW: The times are offset to account for the server time being -6hrs!

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.