Kibit Posted April 23, 2008 Share Posted April 23, 2008 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... Quote $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. Quote Link to comment https://forums.phpfreaks.com/topic/102505-time-delayed-content/ Share on other sites More sharing options...
litebearer Posted April 23, 2008 Share Posted April 23, 2008 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" Quote Link to comment https://forums.phpfreaks.com/topic/102505-time-delayed-content/#findComment-524968 Share on other sites More sharing options...
Kibit Posted April 24, 2008 Author Share Posted April 24, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/102505-time-delayed-content/#findComment-526456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.