@mindfulness/utils
    Preparing search index...

    Function addMonths

    • Type Parameters

      • DateType extends Date

        The Date type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like UTCDate.

      • ResultDate extends Date = DateType

        The result Date type, it is the type returned from the context function if it is passed, or inferred from the arguments.

      Parameters

      • date: DateArg<DateType>

        The date to be changed

      • amount: number

        The amount of months to be added.

      • Optionaloptions: AddMonthsOptions<ResultDate>

        The options object

      Returns ResultDate

      The new date with the months added

      addMonths

      Add the specified number of months to the given date.

      // Add 5 months to 1 September 2014:
      const result = addMonths(new Date(2014, 8, 1), 5)
      //=> Sun Feb 01 2015 00:00:00

      // Add one month to 30 January 2023:
      const result = addMonths(new Date(2023, 0, 30), 1)
      //=> Tue Feb 28 2023 00:00:00