Date instance method
Returns the locale specific month of the year (0-11) for the specified date.
0 = January, 1 = February etc.
|Returns the locale specific month of the year (0-11) for the specified date. 0 = January, 1 = February etc.|
The code below shows examples of the
getMonth() method of
// Create a Date instance for the current date and time. var todaysDate = new Date(); alert(todaysDate); // Get month as a number. alert(todaysDate.getMonth() + ' = Month as a number'); // Use an array to display the month as a string. var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; alert(months[todaysDate.getMonth()] + ' = Month as a string');