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...
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.
Events 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.
To 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.
Totally 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.
Because 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.
Because 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.
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.