marnusw / date-fns-tz

Complementary library for date-fns v2 adding IANA time zone support
MIT License
1.01k stars 112 forks source link

Parse in timezone using format string #242

Open JRebella opened 1 year ago

JRebella commented 1 year ago

The base date-fns package lets you parse an incomplete date string using a format and a reference time. For example:

parse('15:00', 'HH:mm', new Date());
// Today at 15:00 in the local browser's timezone

What if I want to do the same but instead of using the local browser's timezone, I want to use a specific IANA timezone name like US/Central?

Similar to day.js's tz parse: https://day.js.org/docs/en/timezone/parsing-in-zone

dayjs.tz("12-25-1995", "MM-DD-YYYY", "America/Toronto")