JavaScript setUTCMonth()Method
Examples
Set the month to 4 (April):
d.setUTCMonth(4);
dResult output:
Try it Yourself »
Definition and Usage
The setUTCMonth() method is used to set the month according to Universal Time (UTC).
Note:0 (January) ~ 11 (December)
This method can also be used to set a specific day of the month.
Tip:Coordinated Universal Time, also known as World Unified Time, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the setUTCMonth() method.
Syntax
Parameter Values
| Parameter | Description |
|---|---|
| month | Required. The value to set for the month field of the dateObject, expressed in Universal Time. This parameter is an integer between 0 (January) and 11 (December):
|
| day | Optional. A particular day of the month. An integer between 1 and 31, used as the day field of the dateObject, expressed in Universal Time.
If the current month has 31 days:
If the current month has 30 days:
|
Return Value
| Type | Description |
|---|---|
| Number | The millisecond representation of the adjusted date. |
Technical Details
| JavaScript Version: | 1.3 |
|---|
More Examples
Examples
The following example sets the month to 4 (April) and the date to the 20th:
d.setUTCMonth(4,20);
dOutput in local time:
Try it Yourself »
Examples
Set the date to the last day of the previous month:
d.setUTCMonth(d.getUTCMonth(),0);
dOutput in local time:
Try it Yourself »
Other Extensions
JavaScript Date Object