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