How to Comparing two dates in php

by THavamani 2014-03-21 10:49:45

How can we compare two dates using PHP.

First Get two dates.

Ex:

$date1 = date("2013-11-23");
$date2 = date("2015-10-12");

$firstdate = new DateTime($date1);
$seconddate = new DateTime($date2);

if ($firstdate < $seconddate )
{

/* Do something here */

}


This php code is used to compare two dates.
1308
like
0
dislike
0
mail
flag

You must LOGIN to add comments