My backend sends me a timestamp in the following format: 2019-12-15T20:00:00.000Z
which is UTC time. Now all I need is to pull out the time without modifying it for timezones. I am using date-fns
but every time I try to get the time I either get an Invalid Date
or it modifies the time to the local timezone. Right now my code is:
import { format, parse, parseISO } from 'date-fns'
format(parseISO('2019-12-15T20:00:00.000Z'), 'h:mm a')
What I want is: 8:00 PM but what I get is 3:00 PM because its converting from UTC to EST time (my local timezone). I know I can do things like to IsoString and then parse the string, but I am looking for a way to use date-fns to do it so I don't have to write custom string parsers. There has to be an easy way to just ignore timezones?