Given any timezone, like America/New_York
, how can I figure out in JavaScript if DST (Daylight Savings Time) is in effect? I'm looking for a solution that does not use any big libraries like moment. Using smaller, more specific libraries like tz-offset is fine.
Asked
Active
Viewed 789 times
0

applemavs
- 503
- 3
- 9
- 22
-
https://stackoverflow.com/questions/11887934/how-to-check-if-dst-daylight-saving-time-is-in-effect-and-if-so-the-offset ā Nathan Dawson Mar 23 '21 at 21:06
-
1That question addresses checking if DST is in effect within the local timezone. Iām trying to find out if DST is in effect given any timezone. ā applemavs Mar 23 '21 at 21:21
-
1tz-offset library doesn't handle DST correctly, but [Luxon](https://moment.github.io/luxon/) and [Date-fns-tz](https://github.com/marnusw/date-fns-tz) do. Both are relatively small and support tree-shaking. You could also adapt the approach [here](https://stackoverflow.com/a/36146278/634824) with the one in the link Nathan gave. ā Matt Johnson-Pint Mar 23 '21 at 21:50