Easy Tutorial
❮ Prop Button Name Jsref Match ❯

JavaScript setUTCMonth() Method

JavaScript Date Object

Example

Set the month to 4 (April):

var d = new Date();
d.setUTCMonth(4);

d output:


Definition and Usage

The setUTCMonth() method is used to set the month according to Coordinated Universal Time (UTC).

Note: 0 (January) ~ 11 (December)

This method can also be used to set the day of the month.

Tip: Coordinated Universal Time (UTC), also known as Universal Coordinated Time, World Standard Time, and International 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, using UTC. This is an integer between 0 (January) and 11 (December): -1 is the last month of the previous year. <br> 12 is the first month of the next year. <br> 13 is the second month of the next year.
day Optional. The day of the month. An integer between 1 and 31, used as the day field of the dateObject, using UTC. 0 is the last day of the previous month. <br> -1 is the day before the last day of the previous month. If the current month has 31 days: 32 is the first day of the next month. If the current month has 30 days: 32 is the second day of the next month.

Return Value

Type Description
Number The milliseconds representation of the adjusted date.

Technical Details

| JavaScript Version: | 1.3 | | --- | --- |


More Examples

Example

Set the month to 4 (April) and the day to 20:

d output in local time:

var d = new Date();
d.setUTCMonth(4, 20);
document.write(d);

Example

Set the date to the last day of the previous month:

d output in local time:


JavaScript Date Object

❮ Prop Button Name Jsref Match ❯