This is a question similar to this one.
I'm really tempted to store datetimes in my app as local time rather than as UTC (which is considered a best practice). In the app I have a number of events happening, each assigned to a given location. Always when I display them to the user, I want to show the local time of the event. I.e.:
====================================================================================
Event time (with TZ) | As UTC | As local time | To be displayed |
====================================================================================
2014-01-15 22:30 GMT | 2014-01-15 22:30 | 2014-01-15 22:30 | 2014-01-15 22:30 |
2014-01-15 23:30 GMT+1 | 2014-01-15 22:30 | 2014-01-15 23:30 | 2014-01-15 23:30 |
2014-01-16 00:30 GMT+2 | 2014-01-15 22:30 | 2014-01-16 00:30 | 2014-01-16 00:30 |
====================================================================================
If I decide to store the event times in UTC:
it will be difficult to display them (because with each event I need to have the event's timezone and format the date for that timezone).
it will be very difficult to query them (i.e. if I want to show all events that happened on 2014-01-15 local time I need for each event to compare that event's time with what '2014-01-15' means in that event's timezone. Not sure if this is even possible in SQL...)
If I decide to store the event times as local times:
- I will not be able to compare times of events for different locations (but this is ok for me)
Since in the vast majority of cases in the app I'm interested in the local time (usually displaying the, so called "television time") and there aren't many cases where I'm creating new datetime objects (for which I need the location timezone), I believe saving datetimes as local time is justified in this case.
Do you think it is? What are other downsides of storing local times?
Thanks in advance for your attention and help.