检查数据库中的日期是现在还是更早

I have a php script that looks like this (shortened/edited for clarity of course):

$result = mysqli_query($link, 'SELECT date FROM table');
while ($row = mysqli_fetch_assoc($result)) {
if ($row["date"] < time())
{
do some stuff
}
else
do something else

The date is stored in a DATE field in MySQL. I have no interest in storing time and only the date is stored in that field in XXXX-XX-XX format.

How can I check if the retrieved date is today or earlier? By using time() there, which was the last thing I ended up trying, my script is acting as if all retrieved dates are today or earlier, even when they are not.

Thank you for any help with this.

You should perform the comparison in the SQL query.

Have a look at: mysql date comparison with date_format

You can check if date is today (or earlier) in the SQL statement:

SELECT `date`, `date` <= CURDATE() AS isTodayOrEarlier
FROM table

or

SELECT `date`, IF(`date` <= CURDATE(), 1, 0) AS isTodayOrEarlier
FROM table