getMonth()

The getMonth() method is used to return the month of the year, which is the taken from the date specified by your operating system, and used by the Date object. The value returned is the numeric representation of the month, not the month name.

syntax:

dateName.getMonth()

EXAMPLE

dateObject = new Date();

document.write("The date is: " + dateObject.getMonth());

The example shows the creation of a new Date object, called dateObject. It is then used within a document.write statement, with the getMonth() method to display month of the year after the string of text.