0

I have a .NET application that returns the date in this format: 2021-12-29T15:04:09.0129998. I need a Javascript form to format to "December 29, 2021".

All the examples I've found so far use "new date " to exemplify, like this example here:

const currentDate = new Date();
console.log(currentDate.toLocaleDateString('de-DE'));

that creates a date in a different format from mine and then it works. In my case it doesn't work.

Assis Zang
  • 310
  • 3
  • 11
  • Here's a hint: `const currentDate = new Date('2021-12-29T15:04:09.0129998');` – devlin carnate Dec 29 '21 at 18:37
  • `new Date().toLocaleDateString('en',{month: 'long', day: 'numeric', year: 'numeric'})` will get pretty close. Be careful with `new Date('2021-12-29T15:04:09.0129998')`, it will be parsed as local or an invalid date, see [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results) – RobG Dec 30 '21 at 02:05

1 Answers1

-1
new Date().toDateString("de-DE").substring(3)