PHP date compare
PHP date compare
In this tutorial you will learn how to PHP date compare in a PHP web application. In this tutorial strtotime() function used to convert English textual description into a Unix timestamp ( in second) and compare both dates timestamp . The code of "php-date-compare.php" given below :
<?php
echo "<b>PHP Date compare</b><br>";
$date1=date("Y-m-d");
$date2= strtotime(date("Y-m-d", strtotime( $date1)) . " +2 day");
echo "First date ::".$date1."<br>";
echo "Second date ::".date('Y-m-d', $date2)."<br>";
if(strtotime($date1)>$date2){
echo "Date compare ::".$date1.">".date('Y-m-d', $date2);
}else{
echo "Date compare ::".date('Y-m-d', $date2).">".$date1;
}
?>
Output :
When run "php-date-compare.php" display output as :


[ 0 ] Comments