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