Javascript get month name from number or date

Finding The Month Using JavaScript

// getMonthName Function
getMonthName = function (v) {
    var n = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    return n[v]
}
var d = new Date();

// Print
var print = function (val) {
    document.body.innerHTML = document.body.innerHTML + "<br />" + val
}
// Function Call
print(getMonthName((new Date()).getMonth()) + ' - Current Month')
print(getMonthName(1))
print(getMonthName(6))
print(getMonthName(9))
print(getMonthName(11))
DEMO
Javascript get month name from number or date Javascript get month name from number or date Reviewed by Bhaumik Patel on 7:07 PM Rating: 5