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 numberThe month of the date (0 to 11).


Browser Support

getMonth() is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.