Easy Tutorial
❮ Dom Obj Email Prop Style Perspective ❯

JavaScript getMonth() Method

JavaScript Date Object

Example

Return the month:

n Output result:


Definition and Usage

The getMonth() method returns the month in the specified date according to local time, as a zero-based value (where zero indicates the first month of the year). The return value is an integer between 0 (January) and 11 (December).

Note: January is 0, February is 1, and so on.


Browser Support

All major browsers support the getMonth() method.


Syntax

Return Value

Type Description
Number The return value is an integer between 0 (January) and 11 (December).

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

Now, we will create an array to output the names of the months, instead of a number:

The above example output result:


JavaScript Date Object

❮ Dom Obj Email Prop Style Perspective ❯