$date = new Zend_Date(); // Creating an instance of Zend_Date class $date->addMonth(1); // Adding one month to the current date echo $date; // Output: Current date + 1 month
$date = new Zend_Date('2021-02-28'); // Creating an instance with a specific date $date->addMonth(1); // Adding one month to the given date echo $date; // Output: 2021-03-28
$date = new Zend_Date('2021-02-28'); // Creating an instance with a specific date $date->addMonth(3); // Adding three months to the given date echo $date; // Output: 2021-05-28In these examples, we have used the addMonth() method to add one or multiple months to the current date or a specific date. It is a very useful method when working with dates in PHP. The library used in this example is Zend Framework.