get month name javascript code example
Example 1: javascript month name
let date = new Date(2020, 05, 21);
let longMonth = date.toLocaleString('en-us', { month: 'long' });
let shortMonth = date.toLocaleString('en-us', { month: 'short' });
let narrowMonth = date.toLocaleString('en-us', { month: 'narrow' });
Example 2: Javascript get month name
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date();
var monthName=months[d.getMonth()];
Example 3: current month in javascript
const localDate = new Date();
const months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
let currentMonth = months[localDate.getMonth()];
console.log(currentMonth);