4 ms·
I store my data in UTC anyway. BUT why not include the timezone in the timestamp? Then in your example you can change the server's timezone with no disruption..
by yetanother1980 9y ago
I store my data in UTC anyway. BUT why not include the timezone in the timestamp? Then in your example you can change the server's timezone with no disruption...
- dijit 9y agoBecause it's extra parsing in a pinch? If you're storing it in a database it'll be stored as a 64bit unsigned int (a-la UNIX Epoch) of seconds since 1970 (in UTC) but if it's text-file logs I agree that it should be UTC, this has been standard ops practice for 20~ years.
- sametmax 9y agoSome programs in your server will use the server clock and don't have a timezone settings.
- JumpCrisscross 9y ago> why not include the timezone in the timestamp? I don't think there is an unambiguous way to represent time zones. Time zones are a creation of law and convention. They change, and have changed, over time.
- tzahola 9y agoThere is an unambiguous way to represent time zones: UTC±hh:mm
- deleted 9y ago[deleted]
- BerislavLopac 9y agoTo be pedantic, that's the unambiguous way to represent the UTC offset, not timezones. Different timezones can have the same offset at some moments, but not at others.
- tzahola 9y agoGGP probably meant including the UTC offsets in the timestamps, not timezone names like "Europe/Berlin" or whatever.
- icebraining 9y agoRight, but the time zone might not have the same offset in the future, they're not interchangeable.
- toast0 9y agoEvents in the past are easy: all you really need is UTC time, but if you store local time and the offset from UTC (and optionally the tzdata timezone name) that works too. For dates in the future, you need to store local time, the timezone name, and the calculated offset for that time. When the database changes, you need to check if the offset changes, and if so, think hard about what that means. Also, some future events are more appropriately scheduled for local time wherever the person happens to be, which is tricky too.
- petre 9y agoYes there is. It's called ISO 8601. https://en.m.wikipedia.org/wiki/ISO_8601 https://en.m.wikipedia.org/wiki/ISO_8601
- dschuler 9y agoTotally agree! I've run into this problem quite a bit, and I think storing the timezone or offset along with a UTC timestamp is the solution. In particular, I want to be able to: 1. Know when a globally ordered even happens. Using UTC or local time with offsets satisfies this requirement. 2. Know when an event occurred in local time, for example movie show times (I can't know what time to print on the ticket without getting the theater's time zone when passed in UTC). UTC does not solve this problem, but local time with offsets works. Example of when I wrote this comment: $ date -u +"%Y-%m-%dT%H:%M:%SZ" 2018-02-08T16:17:48Z $ date +%FT%T%z 2018-02-08T08:17:48-0800 Both formats are ISO8601 compatible. Finally, many client-side requests for dates should be in local wall time without an offset or UTC. Of course this is application dependent, but I've seen this go wrong a few times. Please share other ideas/suggestions if you have them.
- tome 9y agoBecause then it's denormalized and it's failing to separate concerns. It's storing both the time something happened and the thing strip of longitude it was nominally deemed to have taken place in.
- dllthomas 9y agoA timezone is a political boundary, not "a thin strip of longitude" (unfortunately)