Skip to content
Advertisements

JavaScript Date.getMonth()

Why getMonth ?

JavaScript Date The getMonth () method handles the specified date. returns the month of the date as a result of this operation.

  • january 0
  • february 1
  • mart 2
  • april 3
  • may 4
  • june 5
  • july 6
  • august 7
  • september 8
  • October 9
  • november 10
  • december 11

Syntax:

Date.getMonth()

return: It returns the Month for the given Date object. Month is an integer value ranging from 0 to 11. Zero (0) means January, 1 means February and so on till 11 means December.


JavaScript getMonth Examples

Example 1

With the getMonth method, you can access the current month.

        var now = new Date('July 21, 1983 01:15:22');
        console.log(now.getMonth());

6


Example 2

        var date = new Date('April 21, 1983 22:47:55');
        console.log(date.getMonth());

3


Example 3

        var date = new Date('October 21, 1983 ');
        console.log(date.getMonth());

9


Browser Support

Chromeyes
Edgeyes
Firefox1
Internet Exploreryes
Operayes
Safariyes
Android webviewyes
Chrome for Androidyes
Edge mobileyes
Firefox for Android4
Opera Androidyes
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: