0

I am trying to transform a date in javascript from the following string:

Tue Jul 27 2021 00:00:00 GMT+0200 (hora de verano de Europa central)

To:

Tue, 27 Jul 2021

I have tried in various ways but I cannot achieve the format I want, if someone could help me I would greatly appreciate it.

Thanks

Juan
  • 21
  • 3
  • Does this answer your question? [How to format a JavaScript date?](https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – Heretic Monkey Jun 24 '21 at 14:53
  • Please show the code where you are seeing this string. Are you sure it's a string and not a `Date` object? – Heretic Monkey Jun 24 '21 at 14:54
  • `'Tue Jul 27 2021 00:00:00 GMT+0200 (hora de verano de Europa central)'.substring(0,15).replace(' ',', ')` is pretty close. – RobG Jun 25 '21 at 00:48
  • Or there is `let [dayName, month, day, year] = date.split(' '); console.log(\`${dayName}, ${day} ${month} ${year}\`)`. :-) – RobG Jun 25 '21 at 00:53

0 Answers0