English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript setUTCMonth() method

 JavaScript Date Object

setUTCMonth()The method sets the month in the Date object according to UTC (0 ~ 11)。

If the specified parameter is out of the expected range (from 0 to11),thenThe setUTCMonth() method willtry to update the date information in the Date object accordingly.

For example, if you set15used asmonththe value, the year will increase1, and3will be used as the month.

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

World Standard Time (UTC) is the time standard set for world time.

Syntax:

date.setUTCMonth(month, day)
var d = new Date();
d.setUTCMonth(11);
Test and See‹/›

If not specifieddayIf the parameter is not specified, the value returned by the getUTCDate() method is used.

Browser Compatibility

All browsers fully support the setUTCMonth() method:

Method
setUTCMonth()IsIsIsIsIs

Parameter Value

ParameterDescription
month(Required) 0 to11An integer between the two represents the month from January to December
day(Optional)1to31An integer between the two represents a specific day in a month

Technical Details

Return Value:1970 years1Month1Milliseconds between 00:00:00 UTC and the update date
JavaScript Version:ECMAScript 1

More Examples

Specify16As the month value:

var d = new Date();
d.setUTCMonth(16);
Test and See‹/›

 JavaScript Date Object