For php version >=5.3 : Create two date objects and then use date_diff()
function. It will return php DateInterval object. see documentation
$date1=date_create("2007-03-24");
$date2=date_create("2009-06-26");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");