-1
  • Given-2020-11-23T04:08:22.361Z.
  • Expected-Sep 08, 2020 09:24:05 UTC. (sample)

I have tried using .toUTCString() in javascript it returned "Mon, 23 Nov 2020 04:08:22 GMT" Is there any other way to get the exact same format as expected

  • This may help https://stackoverflow.com/a/9756189/3266552 – manu Nov 23 '20 at 05:21
  • @manu in the link which u shared were all using newDate() , in my case i have different dates in the given format and i want to convert to expected – Ben Franklin Nov 23 '20 at 11:34

1 Answers1

1

You can use moment.js (https://momentjs.com/) It has an extensive set of methods for dates and time.

You can install it using

npm install moment

and then import in the file you need it in like

import moment from 'moment';

Use can use then make use of utc parser to parse your date to required format

moment.utc().format(<date>)
Sapna Dhalor
  • 86
  • 1
  • 8