ItSolutionStuff.com

How to Add Months to Date in PHP?

By Hardik Savani • May 14, 2024
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: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Extract All Email Addresses from String in PHP?

Read Now →

How to Get HTML Tag Value in PHP?

Read Now →

Laravel Carbon Get Yesterday Date Example

Read Now →

PHP Dropzone File Upload on Button Click Example

Read Now →

PHP Check If Array Is Multidimensional or Not

Read Now →

PHP - How to Reindex Array Key After Unset Key?

Read Now →

Laravel 11 File Upload with Progress Bar Example

Read Now →

How to Find Day Name from Specific Date in PHP?

Read Now →

How to Remove Null Values from Array in PHP?

Read Now →