I\'m creating a function to check which date, in a database table full of date\'s, is smaller then then current date. As in the past.
I\'ve got 3 date\'s to test the fun
Your "dates" are really strings. And when comparing them it is alphabetical. You need to convert those dates to real dates for this to work:
$dateNow = new DateTime();
$deadlineDate = DateTime::createFromFormat("d-m-Y H:i:s", "28-04-2015 16:33:18");
if($deadlineDate < $dateNow){ //If date from last month is smaller then the current date
echo ''; //Overdue class gives that tr an red background color to mark it
echo ''.$deadlineDate.' is smaller then '.$dateNow.' ';
}else{
echo ' ';
echo ''.$deadlineDate.' is bigger dan '.$dateNow.' ';
}
Converting them into YYYY-MM-DD format will also work.
- 热议问题