xxxxxxxxxx
const currentDate = new Date();
const currentMonth = currentDate.getMonth();
console.log(currentMonth);
xxxxxxxxxx
// Make an instance or object of the Date constructor
const currentDate = new Date();
// get the current month number
const monthNumber = currentDate.getMonth();
console.log(monthNumber); // eg: 8
xxxxxxxxxx
const date = new Date();
const month = date.toLocaleString('default', { month: 'long' });
console.log(month);
xxxxxxxxxx
const today = new Date()
today.toLocaleString('default', { month: 'long' })
// GET DYNAMIC MONTH STRING
const monthtostring = month => new Date(`${month}/01/2032`).toLocaleString('en-US', { month: 'long' })
monthtostring(8) // August
const monthtostring = month => new Date(`${month}/01/2032`).toLocaleString('pt-BR', { month: 'long' })
monthtostring(03) // março
xxxxxxxxxx
var Xmas95 = new Date();
var options = { month: 'long'};
console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95));
// December
console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95));
// Dezember