Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.getMonth

Returns the month — a number from 0 to 11.

Available since: ES1

Syntax

date.getMonth()

Return value

numberThe month number from 0 (January) to 11 (December).

Examples

March is 2, not 3:

const date = new Date(2026, 2, 15);
 
console.log(date.getMonth());
console.log(date.getMonth() + 1);

Output:

2
3

The month name from an array:

const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
 
console.log(months[new Date(2026, 2, 15).getMonth()]);

Output:

Mar

Notes

To show the month number to a person, add 1. A month name in any language is easier to get from toLocaleDateString() with the month option.

See also

Related recipes

In the tutorial

  • Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.

Thanks for reading!

Donate to the site — we work hard for you.