DateTime::diff()

It can be used to find out the  difference between two dates
Example

<?php
$datetime1 = new DateTime(‘2009-5-17’);
$datetime2 = new DateTime(‘2012-5-17’);
$interval = $datetime1->diff($datetime2);
echo $interval->format(‘%R%a days’);
?>

Output

+1096 days