With regards to time zones, daylight savings, and web users, is there a best practice for storing date & time information in a database?
For example, my databases are hosted in Time Zone A, but the web users are in Time Zone B. Then, when I create a rss feed (which is displayed in GMT), I add a third time zone into the mix for the same data. To date (no pun intended), I have been entering the date/time data in the time zone of the database server (Time Zone A), and then converting it using an application setting in the web.config file (i.e. TimeZoneBOffset = -1, GMTOffSet = -5). In other words, each time I display a date I calculate what it should be using the time-zone offset in the web.config. This also enables me to account for changes in day light savings, etc.
My concerns are three fold: 1. What if I move the database to another server and the time zone changes? 2. Right now the users are in only 1 time zone. If I expand it to several then the offset will have to be by users, which is do-able, but something I haven't had experience with in the past. 3. It is likely more efficient to calculate the time zone once on input into the DB, rather than in each use like I'm doing now. What time zone baseline for insert into the db should I use?
Thanks in advance for your help!
PS My application is primarily looking at 'smalldatetime' data - down to the 'minute' level.
Hey, this is an old song.
My point is that you have to store date in a universal format - UTC, this will prevent any troubles while moving database on another zone.
Next, your users have to setup theirs profile and specify in what timezone they are in. According to this you're making shifts.
E.g. look at this site, each user has Site Option section where he/she can setup time zone.
I guess it is that simple.
Do you know of any webservice or other source that has time zone data?
Thanks.
|||
Here is a good article on the subject:
http://aspnet.4guysfromrolla.com/articles/081507-1.aspx
No comments:
Post a Comment