-3

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").

Nicolas Gimelli
  • 695
  • 7
  • 19
  • Does this answer your question? [How do I format a date in JavaScript?](https://stackoverflow.com/questions/3552461/how-do-i-format-a-date-in-javascript) – pilchard Jun 01 '22 at 21:33

2 Answers2

1

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".

  • 1
    The duplicate has 2657 votes and completely explains `toLocaleDateString` and all of it's options. Flag to close – pilchard Jun 01 '22 at 21:40
0

try this :

let date = new Date();
let day = date.toLocaleString('en-us', { weekday: 'long' });
let month = date.toLocaleString('en-us', { month: 'long' });

console.log(month);
console.log(day);
pilchard
  • 12,414
  • 5
  • 11
  • 23