Returns the month calculated date with the source date and the specified amount
If the target month does not have the same day, the result is clamped to the last day of the target month
Optional
The date to inspect
The amount to add, negative number means minus
the month calculated date with the source date and the specified amount
David Hsing
addMonth(new Date(2023, 8, 30), 1); // Date(2023, 9, 30)addMonth(new Date(2023, 0, 31), 1); // Date(2023, 1, 28)addMonth(new Date(2023, 2, 31), -1); // Date(2023, 1, 28) Copy
addMonth(new Date(2023, 8, 30), 1); // Date(2023, 9, 30)addMonth(new Date(2023, 0, 31), 1); // Date(2023, 1, 28)addMonth(new Date(2023, 2, 31), -1); // Date(2023, 1, 28)
Returns the month calculated date with the source date and the specified amount
If the target month does not have the same day, the result is clamped to the last day of the target month