setMonth
Commons
stable
Return a new Date with the month replaced by the given zero-based index (0 = January). The original date is never mutated.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- daterequiredDate
- The source date. It is cloned before the month is updated.
- countrequirednumber
- Zero-based month index (0 = January … 11 = December). Values outside 0–11 roll over into adjacent years.
API
Return value
The value returned by this util.
- A new Date object with the specified month.
Usage
Examples
Ready-to-paste usage snippets.
Switch to a different month