Shyju Shyju - 1 year ago 122
Javascript Question

Get month name from Date

How can I generate the name of the month (e.g: Oct/October) from this date object in JavaScript?

var objDate = new Date("10/11/2009");

Answer Source

Shorter version:

var monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"

var d = new Date();
document.write("The current month is " + monthNames[d.getMonth()]);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download