Skip to content

addMonths

The addMonths() function adds a positive number of months to a TheDate. Year rollovers and leap years are handled automatically.

Interactive example

Syntax

Classic signature

typescript
function addMonths<
	GenericInput extends TheDate,
	GenericMonth extends number
>(
	input: GenericInput,
	month: PositiveNumber<GenericMonth>
): TheDate

Curried signature

typescript
function addMonths<
	GenericInput extends TheDate,
	GenericMonth extends number
>(
	month: PositiveNumber<GenericMonth>
): (input: GenericInput) => TheDate

Parameters

  • month: Strictly positive number of months.
  • input: Date to adjust (classic signature).

Return value

A TheDate moved forward by the given number of months.

See also

Released under the MIT license.