PHP Check if date is past to a certain date given in a certain format

You can compare the dates with PHP’s DateTime class:

$date = new DateTime($event['date']);
$now = new DateTime();

if($date < $now) {
    echo 'date is in the past';
}

Note: Using DateTime class is preferred over strtotime() since the latter will only work for dates before 2038. Read more about the Year_2038_problem.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)