English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript getMonth() method

 JavaScript Date Object

getMonth() Returns the month of the specified date object according to local time (0-11()).

getMonth()The returned value is an integer corresponding to the month of the year: 0 represents January,1Represents February, and so on.

For the day of the week, seegetDay()Method.

For a specific day of the month, seegetDate()Method.

Syntax:

date.getMonth()
var d = new Date();
d.getMonth();
Test and see‹/›

Browser Compatibility

The getMonth() method is fully supported by all browsers:

Method
getMonth()isisisisis

Technical Details

Return Value:0 to11are integers between
JavaScript Version:ECMAScript 1

More Examples

Returns 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‹/›

 JavaScript Date Object