date comparison in php code example
Example 1: php compare two dates
$today = date("Y-m-d");
$expire = $row->expireDate;
$today_time = strtotime($today);
$expire_time = strtotime($expire);
if ($expire_time < $today_time) { }
Example 2: date comparison function in php
Select if(Date('2020-10-01') > Date('2020-11-01'), '1', '2' ) as rslt_date
Example 3: php compare dates
$date1 = "2021-01-15";
$date2 = "2021-01-18";
if ($date1 < $date2) {
echo "$date1 is earlier than $date2";
} else {
echo "$date1 is later than $date2";
}