getMonth method
The getMonth method is applied
to the date object
and returns the current month. Months
are numbered from zero.
Syntax
date.getMonth();
Example
Let's output the number of the current month:
let date = new Date();
let res = date.getMonth();
console.log(res);
Example
Let's get the month for a given date:
let date = new Date(2025, 11, 31);
let res = date.getMonth();
console.log(res);
The code execution result:
11
See also
-
the
getDaymethod
that gets the day of the week -
the
getFullYearmethod
that gets the year -
the
getDatemethod
that gets the day of the month -
the
getHoursmethod
that gets the hours -
the
getMinutesmethod
that gets the minutes -
the
getSecondsmethod
that gets the seconds