There is an input of this format:
2021-04-02T16:06:09.61
How can it be formatted to be in DD-MMM-YYYY form?
For example, for the above input it should return 02-Apr-2021
There is an input of this format:
2021-04-02T16:06:09.61
How can it be formatted to be in DD-MMM-YYYY form?
For example, for the above input it should return 02-Apr-2021
 
    
    const d = new Date();
let day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);
let month = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);
let year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
console.log(`${day} ${month} ${year}`); 
    
    you can use this
function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();
    if (month.length < 2) 
        month = '0' + month;
    if (day.length < 2) 
        day = '0' + day;
    return [year, month, day].join('-');
}
 
console.log(formatDate('Sun May 11,2014'));
copied from Format JavaScript date as yyyy-mm-dd
