• Skip to main content
  • Skip to search
  • Skip to select language
HTML

Structure of content on the web

  • Web APIs

    Interfaces for building web applications

  • Learn
    • CSS

      Learn to style content using CSS

    • Overview

      A customized MDN experience

    • FAQ

      Frequently asked questions about MDN Plus

  • HTTP Observatory

    Scan a website for free

  • JavaScript
  • getMonth()
      • Deutsch
      • Español
      • Français
      • 日本語
      • 한국어
      • Português (do Brasil)
      • Русский
      • 中文 (简体)

    In this article

    • Try it
    • Syntax
    • Description
    • Examples
    • Specifications
    • Browser compatibility
    • See also
    1. now()
    2. getDay()
    3. getMinutes()
    4. getTimezoneOffset()
    5. getUTCHours()
    6. getUTCSeconds()
    7. getYear() Deprecated
    8. setMilliseconds()
    9. setTime()
    10. setUTCMilliseconds()
    11. setYear() Deprecated
    12. toLocaleDateString()
    13. toTemporalInstant() Experimental
    14. [Symbol.toPrimitive]()
  • Inheritance
  • call()
  • displayName Non-standard
  • arguments Non-standard Deprecated
  • caller Non-standard Deprecated
  • Instance methods
    1. __defineGetter__() Deprecated
    2. __defineSetter__() Deprecated
    3. __lookupGetter__() Deprecated
    4. __lookupSetter__() Deprecated
    5. toLocaleString()
    6. __proto__ Deprecated
    7. Date instances returns the month for this date according to local time, as a zero-based value (where zero indicates the first month of the year).

  • Try it

    const moonLanding = new Date("July 20, 69 00:20:18");
    
    console.log(moonLanding.getMonth()); / (January gives 0)
    / Expected output: 6
    

    Syntax

    js
    getMonth()
    

    Parameters

    None.

    Return value

    An integer, between 0 and 11, representing the month for the given date according to local time: 0 for January, 1 for February, and so on. Returns NaN if the date is invalid.

    Description

    The return value of getMonth() is zero-based, which is useful for indexing into arrays of months, for example:

    js
    const valentines = new Date("1995-02-14");
    const month = valentines.getMonth();
    const monthNames = ["January", "February", "March" /* , … */];
    
    console.log(monthNames[month]); / "February"
    

    However, for the purpose of internationalization, you should prefer using Intl.DateTimeFormat with the options parameter instead.

    js
    const options = { month: "long" };
    console.log(new Intl.DateTimeFormat("en-US", options).format(valentines));
    / "February"
    console.log(new Intl.DateTimeFormat("de-DE", options).format(valentines));
    / "Februar"
    

    Examples

    Using getMonth()

    The month variable has value 11, based on the value of the Date object xmas95.

    js
    const xmas95 = new Date("1995-12-25T23:15:30");
    const month = xmas95.getMonth();
    
    console.log(month); / 11
    

    Specifications

    Specification
    ECMAScript® 2026 Language Specification
    # sec-date.prototype.getmonth

    Browser compatibility

    See also

    • Date.prototype.getUTCMonth()
    • Date.prototype.setMonth()

    Help improve MDN

    Date object represents a single moment in time.","name":"Date"}},"browserCompat":["javascript.builtins.Date.getMonth"],"pageType":"javascript-instance-method"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant