Compare Two Date Script

Compare Two Date Script is use to compare two dates and which is the highest date you see it.

Demo :

Date 1 : Date 2 :    

Code :

Following code is use to PHP Compare Two Date Script code if you need to copy and use to your website.

$date1 = mktime(0,0,0,1,26,2011);
$date2 = mktime(1,0,0,1,26,2011);
if ($date1 > $date2)
    $str = date ("d-M-Y H:i:s", $date2) . " comes before " .date ("d-M-Y H:i:s", $date1);
else if ($date2 > $date1)
    $str = date ("d-M-Y H:i:s", $date1) . " comes before " .date ("d-M-Y H:i:s", $date2);
    $str = "Dates are equal";
echo $str;

PHP's comparison operators work just as well on temporal values as they do on numbers and strings. This is illustrated in the previous listing, which compares two dates to see which one precedes the other.

Free Download Script :

If you need to Compare Two Date Script click and download from following link.