JavaScript setUTCMonth () method
Examples
The month is set to 4 (April):
var d = new Date ();
d.setUTCMonth (4);
d.setUTCMonth (4);
d resulting output:
try it"
Definition and Usage
setUTCMonth () method is used to set the month when the World (UTC).
Note: 0 (January) to 11 (December)
This method can be applied to set up a day of the month.
Tip: Coordinated Universal Time, also known as the unified world time, Universal Time, Coordinated Universal Time, abbreviated UTC (Universal Coordinated Time).
Browser Support
All major browsers support setUTCMonth () method
grammar
Date.setUTCMonth( month , day )
Parameter Value
参数 | 描述 |
---|---|
month | 必需。要给 dateObject 设置的月份字段的值,用世界时表示。
该参数是 0(一月) ~ 11(十二月) 之间的整数:
|
day | 可选。月份中的某一天。
在 1 ~ 31 之间的整数,用作 date Object 的天字段,用世界时表示。
如果当月有31天:
如果当月有30天:
|
return value
Type | 描述 |
---|---|
Number | 调整过的日期的毫秒表示。 |
technical details
JavaScript version: | 1.3 |
---|
More examples
Examples
The following examples set March 4 (April) No. 20 dated:
var d = new Date();
d.setUTCMonth(4,20);
d.setUTCMonth(4,20);
d in local output:
try it"
Examples
Set the date for the last day of the previous month:
var d = new Date();
d.setUTCMonth(d.getUTCMonth(),0);
d.setUTCMonth(d.getUTCMonth(),0);
d in local output:
try it"