Answers for "get month in letters 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
0

how to write a program that alerts the current month in words in javascript

var currentDate = new Date();
currentDate.toString;
var b = currentDate.toString();
var c = b.slice(4,7);
if (c === "Jan"){
    document.write("Current month: January")
}else if(c === "Feb"){
    document.write("Current month: February")
}else if(c === "Mar"){
    document.write("Current month: March")
}else if(c === "Apr"){
    document.write("Current month: April")
}else if(c === "May"){
    document.write("Current month: May")
}else if(c === "Jun"){
    document.write("Current month: June")
}else if(c === "Jul"){
    document.write("Current month: July")
}else if(c === "Aug"){
    document.write("Current month: August")
}else if(c === "Sep"){
    document.write("Current month: September")
}else if(c === "Oct"){
    document.write("Current month: October")
}else if(c === "Nov"){
    document.write("Current month: November")
}else if(c === "Dec"){
    document.write("Current month: December")
}
Posted by: Guest on June-21-2020

Code answers related to "get month in letters javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language