Answers for "get full month name in javascript"

20

javascript month name

let date = new Date(2020, 05, 21); // 2020-06-21
let longMonth = date.toLocaleString('en-us', { month: 'long' }); /* June */
let shortMonth = date.toLocaleString('en-us', { month: 'short' }); /* Jun */
let narrowMonth = date.toLocaleString('en-us', { month: 'narrow' }); /* J */
Posted by: Guest on June-21-2020
17

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()]; // "July" (or current month)
Posted by: Guest on July-31-2019
1

javascript get month name from number

export  const GetDatMonthFromDate=(dateSplit:any)=>{
    dateSplit = dateSplit.split('-');
    var monthShortNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
        ];
   var  months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

    const date = new Date(dateSplit[0], dateSplit[1], dateSplit[2]); // 2020-06-21
    return dateSplit[2]+' '+ monthShortNames[date.getMonth()];
}

GetDatMonthFromDate('2021-07-2');

//output = 2 sep;

// if you wanty full month then use months instead of monthShortNames on
// line number 9

//return dateSplit[2]+' '+ months[date.getMonth()];  output == 2 September
Posted by: Guest on August-31-2021

Code answers related to "get full month name in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language