Home > Net >  How to format date in Javascript in this format: 2021-12-29T15:04:09.0129998
How to format date in Javascript in this format: 2021-12-29T15:04:09.0129998

Time:12-30

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.

CodePudding user response:

You can use moment.js to do that. Here is an example how to use the library

from SandBox

CodePudding user response:

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