Date.prototype.setUTCMonth()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
ThesetUTCMonth() method ofDate instances changes the month and/or day of the month for this date according to universal time.
In this article
Try it
const event = new Date("December 31, 1975 23:15:30 GMT-3:00");console.log(event.toUTCString());// Expected output: "Thu, 01 Jan 1976 02:15:30 GMT"console.log(event.getUTCMonth());// Expected output: 0event.setUTCMonth(11);console.log(event.toUTCString());// Expected output: "Wed, 01 Dec 1976 02:15:30 GMT"Syntax
setUTCMonth(monthValue)setUTCMonth(monthValue, dateValue)Parameters
monthValueAn integer representing the month: 0 for January, 1 for February, and so on.
dateValueOptionalAn integer from 1 to 31 representing the day of the month.
Return value
Changes theDate object in place, and returns its newtimestamp. If a parameter isNaN (or other values that getcoerced toNaN, such asundefined), the date is set toInvalid Date andNaN is returned.
Description
If you do not specify thedateValue parameter, the value returned from thegetUTCDate() method is used.
If a parameter you specify is outside of the expected range,setUTCMonth()attempts to update the date information in theDate object accordingly.For example, if you use 15 formonthValue, the year will be incremented by1, and 3 will be used for month.
Examples
>Using setUTCMonth()
const theBigDay = new Date();theBigDay.setUTCMonth(11);Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-date.prototype.setutcmonth> |