How to compare two dates in php if dates are in format \'03_01_12\'
and \'31_12_11\'
.
I am using this code:
$date1=date(\'
Try this
$data1 = strtotime(\date("d/m/Y"));
$data1 = date_create($data1);
$data2 = date_create("21/06/2017");
if($data1 < $data2){
return "The most current date is date1";
}
return "The most current date is date2";
compare the result of maketime()
for each of the time
You can to converte for integer number and compare.
Eg.:
$date_1 = date('Ymd');
$date_2 = '31_12_2011';
$date_2 = (int) implode(array_reverse(explode("_", $date_2)));
echo ($date_1 < $date_2) ? '$date_2 is bigger then $date_1' : '$date_2 is smaller than $date_1';