getMonth()

ES1+

Returns the month (0-11) in the specified date according to local time.

Syntax

date.getMonth()

Return Value

number

A number (0-11) representing the month

Examples

JavaScript
const date = new Date('2024-03-15');
console.log(date.getMonth()); // 3월은 2
console.log(date.getMonth() + 1); // 실제 월
Output:
// 2 3

Related Methods