This question already has an answer here:
here is my current issue: I need to add a predefined amount to a selected date. I have been using this until now:
$date=date('Y-m-d', strtotime('+7 days'));
but this returns the current date +7 days.
How can I define the current date and the modify that using this? lets say that I have the date defined as:
$udate='2014-05-06';
I need to add 2 months to this date.
</div>
You can do,
date('Y-m-d',strtotime(date("Y-m-d", strtotime($your_date)) . " +2 months"));
You can also do using DateTime object,
$date = new DateTime($your_date);
$interval = new DateInterval('P2M');
$date->add($interval);
echo $date->format('Y-m-d')
you can use:
$date = "2014-08-25";
$newdate = strtotime ( '+2 months' , strtotime ( $date ) ) ;
$newdate = date ( 'Y-m-d' , $newdate );