I'm using PHP to insert events from a SQL database into a table in HTML, and I'm trying to make it only display future events (or events taking place the same day). The events are stored in the SQL database with "start" column having dates like 2014-12-25 00:00:00
.
I was previously using this code to display all the dates:
while($row = mysql_fetch_array($result)){
echo "<tr><td>" . $row['title'] . "</td><td>" . date("l, F d Y", strtotime($row['start'])) . " </td></tr>";
}
And it worked fine. When I tried to compare the dates to yesterday (to ensure that events today would display) the HTML page was completely blank. Here's the code I'm using:
while($row = mysql_fetch_array($result)){
if(strtotime("yesterday") < strtotime($row['start'])) {
echo "<tr><td>" . $row['title'] . "</td><td>" . date("l, F d Y", strtotime($row['start'])) . "</td></tr>";
}
}
I don't see anything wrong with this, but for some reason it works. I did some debugging and
strtotime($row['start'])
outputs 1419483600
strtotime ("yesterday")
outputs 1419742800
What am I doing wrong?