In the above syntax, DateObj is a valid Date object created using Date() conctructor from which we want to fetch months.
Parameter: This function does not takes any parameter. It is just used along with a Date Object from which we want to fetch Months.
Return Value: 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.
Below program illustrate the date.getMonth() method:
Errors and Exceptions:
Application: It has many applications such as getting current month. Below program shows one of the applications of this function. It gives the current month.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.