How to get month name from Date inJavascript?

+1 vote
1,622 views
asked May 5, 2018 by Hitesh Garg (799 points)  
edited May 21, 2021 by Hitesh Garg

How get the name of the month from a date object in Javascript (e.g: Jan)?

var objDate = new Date();

2 Answers

+1 vote
answered May 6, 2018 by Rahul Singh (682 points)  
selected Jan 27, 2019 by Hitesh Garg
 
Best answer

I can give two simple solutions

let monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
let date = new Date();
console.log(date.getDate() + " " + (monthNames[date.getMonth()]) + "," + date.getFullYear());

And the other one is

let date = new Date();
console.log(date.getDate() + " " + (date.toLocaleString("en-us", { month: "short" })) + ", " + date.getFullYear());
0 votes
answered Feb 26, 2021 by nijaanil (10 points)  

Thank you Rahul. I am looking for the same, The first Coding you mentioned here works for me

commented May 25, 2021 by Tom Bezlar (10 points)  
Cool!
I had the exact same problem!
Thank you  Rahul!
...