getMonth method

The getMonth method is applied to the date object and returns the current month. Months are numbered from zero.

Syntax

javascriptdate.getMonth();

Example

Let's output the number of the current month:

javascriptlet date = new Date();
let res = date.getMonth();

console.log(res);

Example

Let's get the month for a given date:

javascriptlet date = new Date(2025, 11, 31);
let res = date.getMonth();

console.log(res);

The code execution result:

javascript11

See also

  • the getDay method
    that gets the day of the week
  • the getFullYear method
    that gets the year
  • the getDate method
    that gets the day of the month
  • the getHours method
    that gets the hours
  • the getMinutes method
    that gets the minutes
  • the getSeconds method
    that gets the seconds