English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
getMonth() 根据本地时间返回指定日期对象的月份(0-11)
getMonth()返回的值是与一年中的月份对应的整数:0表示一月,1表示二月,依此类推。
对于星期几,请参见getDay()方法。
有关每月的某天,请参见getDate()方法。
date.getMonth()
var d = new Date(); d.getMonth();Test and see‹/›
All browsers fully support the getMonth() method:
Method | |||||
getMonth() | is | is | is | is | is |
Return Value: | 0 to11integer between the two, representing the month of the year |
---|---|
JavaScript Version: | ECMAScript 1 |
Return the month of the year from a specific date and time:
var d = new Date('August 20, 1999 23:15:30'); d.getMonth();Test and see‹/›
The month variable stores the name of the month:
var arr = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; var d = new Date(); var month = arr[d.getMonth()];Test and see‹/›