php check if time is less than the current time

php check if time is less than the current time

php check if time is less than the current time


 $date_now = new DateTime();
 $date2    = new DateTime("01/02/2016");

if ($date_now < $date2) {
    echo 'less than';
}else{
    echo 'greater than';
}

PHP check if time is greater than the current time


 $date_now = new DateTime();
 $date2    = new DateTime("01/02/2016");

if ($date_now > $date2) {
    echo 'greater than';
}else{
    echo 'less than';
}

Please add your answer below

Scroll to Top