If I have a date object in JS, how can I get a string in the form "Monday, January 12, 2022"? (I do not want abbreviations like "Mon" or "Jan").
CodePudding user response:
You can use date_object.toLocaleDateString('en-us', { year:"numeric", month:"long", day:"numeric", weekday:"long"}).
As I write this, new Date().toLocaleDateString('en-us', { year:"numeric", month:"long", day:"numeric", weekday:"long"}) gives the result "Wednesday, June 1, 2022".
CodePudding user response:
try this :
const date = 'Monday, January 12, 2022';
const getStr = date.replace(/[0-9]/g, '');
console.log(getStr ); // 