addMonths()function

addMonths(change: number, target?: PossibleDate, caller: AnyCaller = addMonths): Date
ParamType
changenumber
required
targetPossibleDate
Values that can be converted to dates.
callerAnyCaller
Any calling function or constructor, usually referring to something that can call in the current scope that can appear in a stack trace. Defaults to addMonths
Return
Date

Return a new date that increase or decreases the month based on an input date.

  • Note that with Javascript "rollover" semantics, adding a month when we're on e.g. 31st of August would normally roll past September and return 1st October.
  • To avoid this we clamp the date to the end of the month if rollover happens.