@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function addMonths

    • Returns a new Date with months added. Accepts negative values to subtract months.

      Parameters

      • date: Date

        The base date.

      • months: number

        Number of months to add.

      Returns Date

      addMonths(new Date("2024-01-15"), 2)  // => 2024-03-15
      addMonths(new Date("2024-01-31"), 1) // => 2024-02-29 (clamped to last day)