How to Add Months to Date in PHP?

By Hardik Savani May 14, 2024 Category : PHP

Today, i would like to show you how to add months to date in php. you will learn how to add 6 months to current date in php. if you have question about php add months to date then i will give simple example with solution. We will use php add 1 month to current date.

I will give you very simple example how to add months to date in PHP. so let's see both example with output:

Example 1: PHP Add Months to Date

index.php

<?php

$date = "2021-11-01";

$newDate = date('Y-m-d', strtotime($date. ' + 3 months'));

echo $newDate;

?>

Output:

2022-02-01

Example 2: PHP Add Months to Current Date

index.php

<?php

$newDate = date('Y-m-d', strtotime(' + 4 months'));

echo $newDate;

?>

Output:

2022-03-01

i hope it can help you...

Tags :
Shares