3 ms·
This is why you always normalize your timestamps to UTC for storage/logging. To explain in a bit more detail, here's a thought experiment. You are in Californ
by kbenson 13y ago
This is why you always normalize your timestamps to UTC for storage/logging. To explain in a bit more detail, here's a thought experiment. You are in California, and it's 2012-11-04 1:30 AM. You need to save this time to refer to it later (pick your favorite reason).
If you assume you are storing times in your time zone, why can't you determine the correct time the timestamp refers to at a later date?
Why is your location important?
- claudius 13y agoWouldn't DST have two different time zones? Over here it is CET/CEST, so if I were to store a date within that hour and its timezone, that would be as good as storing it in UTC, given that the timezone gives just the current offset from UTC.
- apaprocki 13y agoNit: You're referring to the UTC offset, which is not the same thing as a timezone. The offset lets you easily get back to UTC as you say, but only for the datetime in question. A (machine readable) timezone would be something like America/Los_Angeles and wouldn't disambiguate the timestamp. (You don't know whether it was pre- or post-transition without an offset.) The timezone does, however, let you always unambiguously convert UTC to a local datetime with offset. Abbreviations like CET/CEST aren't standardized -- just read the tz mailing list for all the recurring drama regarding the abbreviations in Australia.