Get current month in Javascript

var now = new Date()
var month = now.getMonth()
var ar = new Array(12)
ar[0] = "January"
ar[1] = "February"
ar[2] = "March"
ar[3] = "April"
ar[4] = "May"
ar[5] = "June"
ar[6] = "July"
ar[7] = "August"
ar[8] = "September"
ar[9] = "October"
ar[10] = "November"
ar[11] = "December"
var message = "It is now " + ar[month] + "<BR>"
document.write(message)

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.