date_diff

It is an alias of DateTime::diff()  and can be used to find out the  difference between two dates
Example

<?php
$date1 = date_create(‘2009-5-17’);
$date2 = date_create(‘2012-5-17’);
$interval = date_diff($date1, $date2);
echo $interval->format(‘%R%a days’);
?>

Output

+1096 days

Share