What gotchas should we look out for when storing dates / times as GMT [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this questionI want to store all my dates / times in GMT so basically whenever a user gives in a datetime i will examine what time offset he is, convert that date into GMT, and store it in DB. Dates stored in DB are all assumed to be GMT. Then when he requires that date again, i will retrieve that date from DB, examine his offset, then do the offset accordingly.
I don't really understand about DST and stuff like that. I'm wondering if there will be any "problems" somewhere if i use this design throughout all my project (and my fu开发者_开发问答ture projects)? Is the model flawed in any way or am i missing out something?
You want to use UTC not GMT. GMT is still subject to summer time depending where your server is located. It's not a good choice. Most of the gotchas will be related to trying (and failing) to convert from one timezone to another which becomes arbitrarily complicated since timezones and various daylight savings are always evolving. You avoid all that by ensuring that your backend consistently deals with UTC only and keep local rules/adjustments in the presentation layer.
精彩评论