Skip to content

addMonths

The addMonths() function adds a 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 | SerializedTheDate,
	GenericMonth extends number
>(
	input: GenericInput,
	month: GenericMonth
): TheDate

Curried signature

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

Parameters

  • month: Number of months.
  • input: TheDate or SerializedTheDate.

Return value

A TheDate moved forward by the given number of months.

See also

Released under the MIT license.