PHP date compare

PHP date compare


Posted in : PHP Posted on : January 24, 2011 at 7:08 PM Comments : [ 0 ]

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 :

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics