let month = date.getMonth() + 1; return month < 10 ? '0' + month : '' + month; code example
Example 1: Javascript get month name
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date();
var monthName=months[d.getMonth()]; // "July" (or current month)
Example 2: javascript getmonth
new Date().getMonth(); //note that Jan=0, Dec=11 (annoying I know)