I'm working on a project where I have to gather data from GPS devices located in different countries (timezones + daylight savings) and display those data to different users also from different countries. I'm thinking about saving the date in UTC format (that is what I receive from the GPS device) but then again I belive I'll have trouble converting that date to the user's local date (I have to display historical data also so I'll have to account for daylight savings for the given date). Maybe the datetimeoffset datatype would be more appropriate but how would I go about converting the received UTC date to the datetimeoffset datatype? What would you suggest? Thanks!
Asked
Active
Viewed 350 times
1
-
1What variety of SQL? MySQL? SQLite? SQL Server 2000/2005/2008? – MatBailie Jan 10 '12 at 08:16
1 Answers
2
As you don't have to store any time zone along with the datetime, you can store them as UTC. That has the advantage of being linear, and easy to document. You don't have to bother with gaps and overlaps at the daylight savings time switches.
Convert the date to the local time zone when you display it to the user. It doesn't make sense to convert it to a local time zone until you know which user will be viewing the data.

Guffa
- 687,336
- 108
- 737
- 1,005
-
Do you know of any method for converting a UTC date to LocalDate (even historical data)? Don't I need to know if there was a daylight saving time for any given historical date I have to present to a user? My point is illustrated by this article http://blogs.msdn.com/b/bartd/archive/2009/03/31/the-death-of-datetime.aspx. Also this question is relevant to what I'm asking http://stackoverflow.com/questions/1205142/tsql-how-to-convert-local-time-to-utc-sqlserver2008 – sdagkas Jan 11 '12 at 09:02
-
I choose to store the dates in UTC format, send the dates in unix format to the client and convert it to local time from javascript. – sdagkas Apr 22 '13 at 19:34