The getMonth() method returns the month ranged from 0 to 11 from the date object in local time.
The getMonth() method returns the month ranged from 0 to 11 from the date object in local time.
January is 0, February is 1, and so on.
Date.getMonth()
None
A Number, from 0 to 11, representing the month
Return the month:
//display the number that represent this month. var d = new Date(); var n = d.getMonth(); console.log(n);//from w ww. j a v a 2s . c o m //Note: 0=January, 1=February etc. //Return the name of the month (not just a number): //display the name of this month. var month = new Array(); month[0] = "January"; month[1] = "February"; month[2] = "March"; month[3] = "April"; month[4] = "May"; month[5] = "June"; month[6] = "July"; month[7] = "August"; month[8] = "September"; month[9] = "October"; month[10] = "November"; month[11] = "December"; var d = new Date(); var n = month[d.getMonth()]; console.log(n);