How to determine if a past date is DST using javascript? I know the date and time and timezone (which is not localtime)

48 Views Asked by At

Timestamp is "2021-08-13 05:30:00" and I know that it is US Central Time. What I don't know is if it is DST or not. So without knowing that I cannot convert to UTC correctly. How would I use javascript to get UTC.

I know date and time and timezone (Central Time specifically), but I do not know if it is DST or not and I do not know it's timezoneoffet from zulu.

console.log(someFunction("2022-06-10 15:16:17", "US/Central Time Zone"));
> 2022-06-10 15:16:17 -6 // wrong
> 2022-06-10 15:16:17 -5 // correct because DST
  • Seems with javascript not natively understanding timezones, timezone names, and DST rules, there is no way to do this without external data and or functions. Which is not a big deal unless you have to process hundreds or thousands of these requests on the client side.

So, I'm looking at trying to get a offset reference once and applying that to all the client side needs. Or passing the clients timezone offset to the server and let the server figure it all out.

0

There are 0 best solutions below