I'm using WordPress as a CMS for a radio station. I'm trying to display an image during certain hours of the day that corresponds to the current show that is on the air.
I found some discussion here:
http://ask.metafilter.com/50423/Rotating-header-based-on-time-of-day
One uses javascript, the other uses PHP. I decided to go with the PHP solution.
I'm not an expert coder, so I have no idea why it's not working. :D
Here's the schedule
1am-6am Show 1
6am-9am Show 2
9am-12pm Show 3
12pm-3pm Show 4
3pm-6pm Show 5
6pm-8pm Show 6
8pm-10pm Show 7
10pm-1am Show 8
Here's the code:
<img src="http://www.domain.com/images/rotation/picture<?php
$hour = date('H'); // hour of the day, 24 hour clock
if ($hour > 1 or $hour < 6) {
$timepic = '0100pic';
} elseif ($hour > 6 or $hour < 9) {
$timepic = '0600pic';
} elseif ($hour > 9 or $hour < 12) {
$timepic = '0900pic';
} elseif ($hour > 12 or $hour < 15) {
$timepic = '1200pic
} elseif ($hour > 15 or $hour < 18) {
$timepic = '1500pic';
} elseif ($hour > 18 or $hour < 20) {
$timepic = '1800pic';
} elseif ($hour > 20 or $hour < 23) {
$timepic = '2000pic';
} elseif ($hour > 23 or $hour < 1) {
$timepic = '2300pic';
} else {
$timepic = 'nobody';
}
echo $timepic;
?>.jpg" alt="On The Air Now" width="340" height="200" />
The image doesn't change from the first image, picture0100pic.jpg.
Any ideas? Also, how would I display these only during weekdays, and using picturenobody.jpg during the weekend?