I Need To Compare Two Date Time Variable in Php for my project what is the best way to compare
$date1 = \"2018-02-06 15:09:44\";
$date2 = \"2018-02-06 16:09:44\
$date1 = "2018-02-06 15:09:44";
$date2 = "2018-02-06 16:09:44";
if(strtotime($date1) < strtotime($date2)) {
echo "date1 less than date2";
} else {
echo "date1 is greater than date2;
}
$date1 = new DateTime("2018-02-06 15:09:44");
$date2 = new DateTime("2018-02-06 16:09:44");
if($date1 > $date2 ) {
// statement
}else {
// other statement
}