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

DateTime::add()

We can add number of of days, months, years, hours and seconds with a DateTime object.

Example

<?php
$date = new DateTime(‘2007-05-05’);
$date->add(new DateInterval(‘P5Y’));
echo $date->format(‘Y-m-d’) . “n”;
?>

Output

2012-05-05