codetrix - v1.5.0
    Preparing search index...

    Function setMonth

    • Sets the month of the given date (1-based, e.g. 1 = January) and returns a new Date instance.

      Parameters

      • date: Date

        The original date.

      • month: number

        The month to set (1–12).

      Returns Date

      A new Date with the updated month.

      setMonth(new Date('2025-01-01'), 12); // → 2025-12-01