I'm looping through a result set of events. I want to restrict events that have already happened from appearing in the output. I can't do this in my SQL query because some of the events have StartDate and EndDate fields, others have just StartDates, so I can't select all the events that start in the past and end in the future.
Anyway, here's my code (simplified):
Code: Select all
$today = date("Y-m-d H:i:s");
$compStartDate = strtotime($StartDate);
$compToday = strtotime($today);
if($compStartDate >= $compToday) {
// output event info here
}
The code doesn't work though - it outputs nothing. I'm confident it's not down to me echoing out the results elsewhere, so the logic of the loop is wrong. Any ideas?