I have a string representing ISO UTC date: 2020-06-08T04:00:00.000Z
(4am on 8th of July UTC).
I create a date-fns
object out of it, so that I can format the displayed string according to needs. So I proceed as follows:
const localDate = parseISO('2020-06-08T04:00:00.000Z');
const formattedDateString = format(localDate, 'MMMM dd, yyyy, EEEE, hh:mm aaa');
However formattedDateString
shows in local time (say your browser is in timezone 1Hr ahead of UTC, it shows ...05 AM
), but I need to show UTC time (no matter browser's timezone), i.e. ... 4 AM
. How do I do that ?
Note: ...
indicates omission to keep the example clear