Date Addition and Subtraction in PHP
While development, you might need to add or subtract date from other date. It’s very easy via PHP date and strtotime functions. Following are few examples.
Add 2 Months in current date.
$required_date = date('Y-m-d', strtotime('+2 month')); echo $required_date;
You can also add years, days, and weeks in date very easily, just replace “month” in above statement by following.
"year" ///for years "day" /// for days "week" /// for weeks
You have learnt how to add days, weeks, and years, so now you can also understand how to subtract, just replace “+” sign to “-” in above statement.
Play with it to learn more and read details on php.net