How to Add Months to Date in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Extract All Email Addresses from String in PHP?
- How to Get HTML Tag Value in PHP?
- Laravel Carbon Get Yesterday Date Example
- PHP Dropzone File Upload on Button Click Example
- PHP Check If Array Is Multidimensional or Not
- PHP - How to Reindex Array Key After Unset Key?
- Laravel 11 File Upload with Progress Bar Example
- How to Find Day Name from Specific Date in PHP?
- How to Remove Null Values from Array in PHP?