I need to get the date format as \'DD-Mon-YYYY\' in javascript. I had asked a question, and it got marked duplicate to jQuery date formatting
But, the answers provi
Use the Moment.js library http://momentjs.com/ It will save you a LOT of trouble.
moment().format('DD-MMM-YYYY');
Pass data changeFormate(15/07/2020)
changeFormate(date) {
let month_names = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
let incomingDateChnge: any = new Date(date);
let incomingDay = incomingDateChnge.getDate();
let incomingMonth = incomingDateChnge.getMonth();
let incomingYear = incomingDateChnge.getFullYear();
if (incomingDay < 10) {
incomingDay = '0' + incomingDay;
}
incomingDateChnge = incomingDay + ' ' + month_names[incomingMonth] + ' ' + incomingYear;
return incomingDateChnge;
}
var today = new Date();
var formattedtoday = today.getDate() + '-' + (today.getMonth() + 1) + '-' + today.getFullYear();
alert(formattedtoday);