Handling Time Zone in JavaScript (2019)
medium.com
medium.com
This stuff isn’t simple y’all. “Just use UTC” is a good half assed approach but it can be lossy for many common operations without even considering use cases (an example is storing appointment times where the appointment is in another TZ and you expect the user to physically attend). It can be absolutely bonkers if you have specific user stories that require both standardized (UTC) time and locale adjustments but your user story doesn’t capture that (an example is any kind of regulation that goes into effect where two regulators have existing time rules that can become inconsistent, including but not limited to TZ changes or observation of leap seconds).
There’s been a bunch of words and brainpower spent saying all of this is too complex and we should just discard locale specific time rules entirely. But unfortunately there’s a huge psychological toll that representation of time can take (people literally get injured and die as well), not to mention legal implications that predate any global kind of time system unification efforts.
Time is (currently fundamentally) a necessary complexity that anyone making software can’t just dismiss without harmful consequences and careful consideration.
I think the correct approach is that "always store times in UTC". Then you adjust for wall-clock time on the client.
So now someone wants to schedule an appointment several months away, at e.g. 4PM in that new timezone. Has the software been updated to know that that 4PM will be in that newly-announced but not yet valid timezone? Otherwise it will store the time with the current UTC offset, which will be the wrong offset the time that appointment arrives.