I have an ISO8601 formatted datetime 2024-12-26T22:22:00+12:00
and I want to be able to format the datetime in both original timezone, in this case 22:22
, and user timezones (I.e. 04:22
for CST)
I am looking for a JS Library (dayjs
, date-fns
or any other) that is capable of doing this without dealing with manual string manipulation.
// Browser timezone (e.g. CST-06:00)
const dateStr = "2024-12-26T22:22:00+12:00";
It’s easy to display date in browser time:
// date-fns
format(parseISO(dateStr), "HH:mm"); // 04:22
// dayjs
dayjs(dateStr).format("HH:mm"); // 04:22
But how I can format time at the original offset? I was not able to find a way to do it with dayjs
and date-fns
// How to display 22:22?