YouTip LogoYouTip

Jsref Getmonth

# JavaScript getMonth() Method [![Image 8: Date Object Reference Manual](#) JavaScript Date Object](#) ## Example Return the month: var d = new Date(); var n = d.getMonth(); _n_ Output: 5 [Try it Β»](#) * * * ## Definition and Usage The getMonth() method returns the month (from 0 to 11) for the specified date, according to local time. **Note:** January is 0, February is 1, and so on. * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The getMonth() method is supported in all major browsers. * * * ## Syntax _Date_.getMonth() ## Return Value | Type | Description | | --- | --- | | Number | Returns an integer, between 0 and 11, representing the month in the specified date according to local time. 0 for January, 1 for February, and so on. | ## Technical Details | JavaScript Version: | 1.0 | | --- | * * * ## More Examples ## Example Now, we will create an array, to output the name of the month, instead of a number: var d=new Date(); var month=new Array(); month="January"; month="February"; month="March"; month="April"; month="May"; month="June"; month="July"; month="August"; month="September"; month="October"; month="November"; month="December"; var n = month[d.getMonth()]; The output of the code above will be: June [Try it Β»](#) * * JavaScript Date Object](#)
← Jsref SetutcfullyearJsref Getminutes β†’