Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141277

JS: parse time to pull out hours and minutes using date-fns, ignroing timezones

$
0
0

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). There has to be an easy way to just ignore timezones?


Viewing all articles
Browse latest Browse all 141277

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>