11-24-2006, 02:01 AM
I am working on making a now playing/coming up next list for our website, shows run from 30mins to 3 hour blocks of time, I have tried to use date() to get the hours and mins then do an if else list to compare the values. But I am running into the problem of date being a string. Could anyone give me some pointers on how to convert the date output into a format that I can use to compare the hours and mins from? Any help would be appreciated.
11-24-2006, 03:24 AM
To compare dates/times it is best to compare them as timestamps. The mktime() function forms timestamps from dates/times. The strtotime() function is also useful in converting dates/times into timestamps.
Without more information about what you are doing the comparison for and how the results are being used, that is as specific of an answer as you can get. You need to post your code and an example of what your data is and an example of what you are trying to accomplish.
11-25-2006, 08:03 PM
Thank you, CFMaBiSmAd
I will give it a try. Basicly the comparison is to find the range of time a show runs and put the show in the now playing box and display the coming up next show. So I was trying to get the date using date('Gi') to get the time ie 1023 and then use that in if else block to find the show. I have also split it using 2 date() calls as in the example.
$hday = date('G');
$mday = date('i');
$show = '';
$upnext = '';
if ($hday = 6 & $mday < 29)
// Joyce Meyer
$show = "<h3>Joyce Meyer</h3>";
$upnext = "<h3>Ken Copeland</h3>";
else if ($hday = 6 & $mday > 29)
// Ken Copeland
$show = "<h3>Ken Copeland</h3>";
$upnext ="<h3>Benny Hinn</h3>";
else if ($hday = 7 & $mday < 29)
// Benny Hinn
$show = "<h3>Benny Hinn</h3>";
$upnext = "<h3>Recipe Tv</h3>";
this is just rough sample of it. Still new to php so might be overlooking something simple, but i think its because I am using date and the date output is considered a string and not a true number. will try using mktime(), strtotime() and see if i can get it. Thank you again for the suggestion.