From http://www.w3schools.com (Copyright Refsnes Data)
JavaScript Date Object
The getMonth() method returns the month, as a number.
| dateObject.getMonth() |
Note: The value returned by getMonth() is a number between 0 and 11. January is 0, February is 1 and so on.
Note: This method is always used in conjunction with a Date object.
Example 1Get the current month:
The output of the code above will be: Try it yourself » |
Example 2Write the name of the current month (not just a number):
The output of the code above will be: Try it yourself » |
More Examples |
Display the current date in different formats
How to use getDate(), getMonth(), and getFullYear() to display the current date in different formats.
JavaScript Date Object
From http://www.w3schools.com (Copyright Refsnes Data)