get month from a date js code example

Example 1: getmonth javascript

var date=new Date();
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 n = month[date.getMonth()];

Example 2: 3 letter months javascript array

var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var today = new Date();

// Show date in "dd-mm-yyyy' format.
var d = today.getDate();
var m = months[today.getMonth()];
var y = months.getFullYear();

console.log(d + "-" + m + "-" + y);