Returns a new Date with months added. Accepts negative values to subtract months.
Date
months
The base date.
Number of months to add.
addMonths(new Date("2024-01-15"), 2) // => 2024-03-15addMonths(new Date("2024-01-31"), 1) // => 2024-02-29 (clamped to last day) Copy
addMonths(new Date("2024-01-15"), 2) // => 2024-03-15addMonths(new Date("2024-01-31"), 1) // => 2024-02-29 (clamped to last day)
Returns a new
Datewithmonthsadded. Accepts negative values to subtract months.