Categories :

How to compare dates greater than in php?

<?php
$today = date(‘d-m-Y’); // Date must be in ‘d-m-Y’ format
$date = “07-07-2020”;

if(strtotime($date) < strtotime($today)){
   echo $date .’ date is smaller than today ‘.$today .’ date’;
}else{
    echo $today .’ date is larger than today ‘.$date .’ date’;
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *