I would like to convert the following numerical date I'm getting after trimming ISO date in Javascript:
2022-03-04
To this:
April 3, 2022
I would like to convert the following numerical date I'm getting after trimming ISO date in Javascript:
2022-03-04
To this:
April 3, 2022
Try:
const objDate = new Date("2022-03-04");
const monthFullName = objDate.toLocaleString('default', { month: 'long' });
const year = objDate.getFullYear();
const day = objDate.getDay()
const result = monthFullName + " " + day +", " + year;
// test
console.log(result);
You can play with it here: https://jsfiddle.net/g6ucfbpa/15/