PHP & FF Matrix for Program Schedule
Posted: 03 July 2009 09:07 AM   [ Ignore ]  
Summer Student
Total Posts:  5
Joined  03-18-2009

This question is for you php guru’s out there. I’m using FF Matrix for each day’s program schedule. The fields are ‘program_start’ and ‘program_end’ (Both are text cell types). The client will be importing from a csv that is already formatted the time as 6:00am. I’ve got the template outputting the data into a table. Now, my goal is to highlight the row of the program that is currently airing. So I figured I would need to use php to determine the start, end, and current times. Then say if “current time is greater than or equal to the start time” AND “current time is less than or equal to the end time” then echo ‘class=“hlght”’.

Usually I can hack my way through bits and pieces found on the web but this one boggles my mind. Here is what I have and it doesn’t work. Can someone please help or give me some sort of direction as to why this isn’t working?

<?PHP
$start  
= date("Hi", strtotime("{program_start}"));
$end  = date("Hi", strtotime("{program_end}"));
$now = date("{current_time format='%H%i'}");

if (
$now <= $start && $now >= $end) {
    
echo "Currently Airing $now";
}
else {
    
echo "$start - $end Already Aired";
}
?>

And this is what is outputting which is incorrect because the 8:00am - 12:00pm Paid Programming should be the ‘current airing’ show.

12:00am   6:00am   Paid Programming   0000 - 0600 Already Aired
6:00am   8:00am   ESPNEWS   0600 - 0800 Already Aired
8:00am   12:00pm   Paid Programming   0800 - 1200 Already Aired
12:00pm   3:00pm   CFL Football - 7/2/09 Winnipeg Blue Bombers @ Edmonton Eskimos   1200 - 1500 Already Aired
3:00pm   4:00pm   ESPNEWS   1500 - 1600 Already Aired
4:00pm   4:30pm   3 Wide Life #501   1600 - 1630 Already Aired
4:30pm   5:00pm   2xtreem Motocross #514   1630 - 1700 Already Aired
5:00pm   5:30pm   Raceline #157   1700 - 1730 Already Aired
5:30pm   6:00pm   Steel Dreams #170   1730 - 1800 Already Aired
6:00pm   8:00pm   ESPNEWS   1800 - 2000 Already Aired
8:00pm   11:00pm   CFL Football - British Columbia Lions @ Saskatchewan Roughriders   2000 - 2300 Already Aired
11:00pm   12:00am   ESPNEWS   Currently Airing 0852

Thank you!

Profile
 
 
Posted: 03 July 2009 10:48 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  329
Joined  08-23-2008

Just to be clear, how are your dates/times being stored - are you using just a text field with 0600 in it or is this a date field?

Profile
 
 
Posted: 03 July 2009 10:52 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  5
Joined  03-18-2009

It’s just a text field with 6:00am. The program schedule csv they will be importing already has the times entered in that way. I don’t think they would be willing to convert them manually.

Profile
 
 
Posted: 03 July 2009 11:09 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  329
Joined  08-23-2008

Think you’ve just got your conditional the wrong way round?

if ($now >= $start && $now <= $end) {
Profile
 
 
Posted: 03 July 2009 11:22 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  5
Joined  03-18-2009

OMG. I feel like such a doofus! haha. It’s always elementary school math that gets me.

Thank you so much!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120519 Total Logged-in Users: 74
Total Topics: 126588 Total Anonymous Users: 48
Total Replies: 665496 Total Guests: 342
Total Posts: 792084    
Members ( View Memberlist )
Newest Members:  musclesseownikaiyuharry295tanyagrey31212sarah123CasERispukgendaleOptimiza