get month number from 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: convert integer month to string month react native
var label = [{month: 9, revenue: 400},
{month: 11, revenue: 500},
{month: 12, revenue: 600}]
var months = [];
var revenue = [];
var m = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
label.forEach(function(value){
var monthName = m[value.month - 1];
months.push(monthName);
revenue.push(value.revenue);
});
console.log('Months Array: ', months);
console.log('Revenue Array:', revenue);