Answers for "get month value from date in javascript"

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
4

how to get only month and year in js

let dateObj = new Date();

let myDate = (dateObj.getUTCFullYear()) + "/" + (dateObj.getMonth() + 1)+ "/" + (dateObj.getUTCDate());
Posted by: Guest on May-14-2020
1

getmonth javascript

var date=new Date();
var month=new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var n = month[date.getMonth()];
Posted by: Guest on August-20-2020

Code answers related to "get month value from date in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language