Sunday 28 July 2019

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';
}
?>

No comments:

Post a Comment