php compare dates with > code example
Example 1: php date compare with today
<?php
$datetime1 = new DateTime('2009-10-11 12:12:00');
$datetime2 = new DateTime('2009-10-13 10:12:00');
if ($datetime1 > $datetime2) {
echo 'datetime1 greater than datetime2';
}
if ($datetime1 < $datetime2) {
echo 'datetime1 lesser than datetime2';
}
if ($datetime1 == $datetime2) {
echo 'datetime2 is equal than datetime1';
}
Example 2: date comparison function in php
Select if(Date('2020-10-01') > Date('2020-11-01'), '1', '2' ) as rslt_date