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\");
You can handle with or without translating to the local language
const objDate = new Date("10/11/2009");
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
if (objDate !== 'Invalid Date' && !isNaN(objDate)) {
console.log(objDate.getDate() + ' ' + months[objDate.getMonth()] + ' ' + objDate.getFullYear())
}
const convertDate = new Date('10/11/2009')
const lang = 'fr' // de, es, ch
if (convertDate !== 'Invalid Date' && !isNaN(convertDate)) {
console.log(convertDate.getDate() + ' ' + convertDate.toLocaleString(lang, {
month: 'long'
}))
}