Get month name from Date in JavaScript
Question:
How to get month name from Date in JavaScript? Answer:
let now = new Date();
let monthName = now.toLocaleString('default', { month: 'long' });
console.log('The month is: ' + monthName);
Description:
The toLocaleString()
method returns a string with a language sensitive representation of this date.
The new locales and options arguments let applications specify the language whose formatting conventions should be used and customize the behavior of the function.
Reference:
toLocaleString manual
Share "How to get month name from Date in JavaScript?"
Related snippets:
Tags:
javascript, date, month name, tolocalestring Technical term:
Get month name from Date in JavaScript