Answers for "compare to date in php output day"

PHP
2

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';
}
Posted by: Guest on February-24-2021
0

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";
}
Posted by: Guest on January-11-2021

Browse Popular Code Answers by Language