Answers for "display 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
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 "display month name in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language