JavaScript Date getMonth()
Examples
Get the month:
const d = new Date();
let month = d.getMonth();
Try it Yourself »
Get the name of the month (not just a number):
const month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
const d = new Date();
let name = month[d.getMonth()];
Try it Yourself »
Description
getMonth()
returns the month (0 to 11) of a date.
January =0, February = 1, ... (see below):
Syntax
Date.getMonth()
Parameters
NONE |
Return Value
Type | Description |
A number | The month of the date (0 to 11). |
Browser Support
getMonth()
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |