How to Add Months to Date in PHP?

 

In this blog, We will be going add months to date in PHP. This can be used to get reports of months using filter search. This code is very simple and can be used in multiple places.


Let's get started with examples,


Add Months to Date PHP


<?php

  

    $date = "2023-06-02";

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

  

    echo $newDate;

  

?>


Output:


2023-09-02



Add Months to Current Date PHP


<?php

  

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

  

    echo $newDate;

  

?>


Output:


2023-09-02


I hope you understood this. If you have any doubt please let me know in comments.