0

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.

  • 2
    Does this answer your question? [How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?](https://stackoverflow.com/questions/11887934/how-to-check-if-dst-daylight-saving-time-is-in-effect-and-if-so-the-offset) – Tushar Gupta Aug 13 '22 at 10:21
  • Did you check the duplicate?? – Alon Eitan Aug 14 '22 at 15:35
  • I do not think so, @Tushar. Or is not obvious. Biggest problem seems to be javascript does not know all the timezone and DST data. So I guess you always have to references something external - which then leads to: what is the best way to do that that is future proof and works cross-platform? – Kelly Cockerell Aug 14 '22 at 15:39
  • @AlonEitan I did. See my comment to @tushar? – Kelly Cockerell Aug 14 '22 at 15:41
  • I added example code to my question to show what I hope to get to. – Kelly Cockerell Aug 14 '22 at 15:43

0 Answers0