Disclosure: I don't use UTC, I set the server to local time. I'm very open to learning why I'm wrong and how I can improve.
Edit #2: thanks, responders – makes perfect sense when you put it that way. Today I learned.
You store some customer records, customer can see them back and see the time of their record.
Now you move to Los Angeles with your server. Do you set your server to EST still, and have a server in a timezone that has nothing to do with anything anymore (and the knowledge of why gets lost as time goes by).
Or do you set it as PST ? And now what, do you convert your entire database ? Or do you add special code to "fix" the time is the entry is "earlier than X" ? And how do you then handle displaying the time in the customer's own timezone, when he said +4, did he mean yours (EST) + 4 and then it's not good for PST ? What if you have some servers in New York and some in Los Angeles then ? How do you compare stuff ?
UTC is great because it forces you to work in a mindset of "it doesn't matter where the server, the customer or me are, this is the base time, and for everyone I offset it to their respective timezone".
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.
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.
UTC±hh:mm
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.
Needless to say, this may cause issues in computers. The only clocks that stay consistent and dependable are the ones in UTC land.
So the people mirror the clocks of their local government, but computers mirror the UTC clocks.
UTC is closer to “consistent and dependable” than local time, but still has leap second issues. TAI is where you go for consistent and dependable.
But nobody knows how, when or why they came to be 23 minutes off ...
Time zones are for people, not machines. The machine does not have a sleep schedule or business hours.
It’s generally best if all your servers have one identical environment – time in UTC, language in english – globally, everywhere.