Cake\Chronos\Traits\ModifierTrait::addMonths PHP Method

addMonths() public method

When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month. ### Example: (new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03 (new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28
public addMonths ( integer $value ) : static
$value integer The number of months to add.
return static
    public function addMonths($value)
    {
        $day = $this->day;
        $date = $this->modify((int) $value . ' month');
        if ($date->day !== $day) {
            return $date->modify('last day of previous month');
        }
        return $date;
    }