English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
setMonth()Method to set the month of the date object.
If the parameter you specify is out of the expected range (from 0 to11),thensetMonth()Try to update the date information in the Date object accordingly.
For example, if you will15Used formonth(Month)Value, the year will increase1, and3Will be used as the month.
This method can also be used to set the day of the month.
date.setMonth(month, day)
var d = new Date(); d.setMonth(11);Test and See‹/›
If not specifieddayIf the parameter is not specified,
All browsers fully support the setMonth() method:
Method | |||||
setMonth() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
month | (Required) 0 to11Integer between |
day | (Optional)1to31Integer between |
Return Value: | 1970 Year1Month1Milliseconds between 00:00:00 UTC and the update date |
---|---|
JavaScript Version: | ECMAScript 1 |
Specify16As the month value:
var d = new Date(); d.setMonth(16);Test and See‹/›