1let date = new Date(2020, 05, 21); // 2020-06-21
2let longMonth = date.toLocaleString('en-us', { month: 'long' }); /* June */
3let shortMonth = date.toLocaleString('en-us', { month: 'short' }); /* Jun */
4let narrowMonth = date.toLocaleString('en-us', { month: 'narrow' }); /* J */
1var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
2var d = new Date();
3var monthName=months[d.getMonth()]; // "July" (or current month)
4
1export const GetDatMonthFromDate=(dateSplit:any)=>{
2 dateSplit = dateSplit.split('-');
3 var monthShortNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
4 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
5 ];
6 var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
7
8 const date = new Date(dateSplit[0], dateSplit[1], dateSplit[2]); // 2020-06-21
9 return dateSplit[2]+' '+ monthShortNames[date.getMonth()];
10}
11
12GetDatMonthFromDate('2021-07-2');
13
14//output = 2 sep;
15
16// if you wanty full month then use months instead of monthShortNames on
17// line number 9
18
19//return dateSplit[2]+' '+ months[date.getMonth()]; output == 2 September
1var Xmas95 = new Date();
2var options = { month: 'long'};
3console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95));
4// December
5console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95));
6// Dezember
7