my Task is so simple but I need to know how to do it with just js,
I have this date 2021-05-06
I want to convert it to this, Fri 7 May
.
how to do this?
my Task is so simple but I need to know how to do it with just js,
I have this date 2021-05-06
I want to convert it to this, Fri 7 May
.
how to do this?
You can do it like this:
const convertDate = (date_string) => {
let date = new Date(date_string)
return `${[ 'Sun', 'Mon','Tue','Wed','Thu', 'Fri','Sat'][date.getDay()]} ${date.getDate()} ${['January', 'February', 'March', 'April', 'May','June','July', 'August', 'September', 'October', 'November', 'December'][date.getMonth()]}`;
}
console.log(convertDate('2021-05-06'))