JavaScript Date getMonth() 方法
- Previous Page getMinutes()
- Next Page getSeconds()
- Go to the Previous Level Manwal ng Tagalikha ng Date ng JavaScript
定義和用法
getMonth()
方法根據本地時間返回指定日期的月份(從 0 到 11)。
註釋:一月為 0,二月為 1,依此類推。
實例
例子 1
返回月份:
var d = new Date(); var n = d.getMonth();
例子 2
返回月份的名稱(不僅是數字):
var d = new Date(); var month = new Array(); month[0] = "January"; month[1] = "February"; month[2] = "March"; month[3] = "April"; month[4] = "May"; month[5] = "June"; month[6] = "July"; month[7] = "August"; month[8] = "September"; month[9] = "October"; month[10] = "November"; month[11] = "December"; var n = month[d.getMonth()];
語法
Date.getMonth()
參數
無參數。
技術細節
返回值: | 数值,從 0 到 11,表示月份。 |
---|---|
JavaScript 版本: | ECMAScript 1 |
浏览器支持
方法 | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
getMonth() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Date
Tutorial:JavaScript Date Format
Tutorial:JavaScript Object Constructor
- Previous Page getMinutes()
- Next Page getSeconds()
- Go to the Previous Level Manwal ng Tagalikha ng Date ng JavaScript