English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
setMonth()Méthode pour définir le mois de l'objet Date.
Si les paramètres spécifiés dépassent les limites prévues (de 0 à11) alorssetMonth()Tentez de mettre à jour les informations de date de l'objet Date de manière correspondante.
Par exemple, si vous allez15Utilisémonth(Month)The value, the year will increase1, while3Will 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 to 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 to11An integer between |
day | (Optional)1to31An integer 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 to see‹/›