Hi, I am trying to get the records out of a mysql database where the time is less than todays date and time -
I have set the column as DateTime in mysql and it is stored as 2014-05-31 15:00:00
$TodayDate = date('Y-m-d H:i:s', time()+28800);
$sttTodayDate=strtotime($TodayDate);
// We Will prepare SQL Query
$STM = $dbh->prepare('SELECT * FROM tbl WHERE kickoff< = :kickofftime ORDER BY kickoff Limit 1');
$STM->bindParam(':kickofftime', $sttTodayDate);
// For Executing prepared statement we will use below function
$STM->execute();
// Count no. of records
$count = $STM->rowCount();
//just fetch. only gets one row. So no foreach loop needed :)
$row = $STM -> fetchAll(PDO::FETCH_ASSOC);
if($results > 0){
//$row = mysql_fetch_array($results);
foreach($results as $row);
$nextGame = $row['game'];
$gameTime = $row['kickoff'];
}
When I echo out $TodayDate I get 2014-05-30 09:03:
When I echo out $sttTodayDate I get 471401465827
But I am not seeing / getting any results from the database. Not sure if what way to correctly format the $TodayDate -
Anyone got any ideas what I am doing wrong ?
Thanks