Hello Mark,
This is a difficult issue to deal with. The problem is that timezone information is not directly available through the web browser. You could use heuristics to determine the correct time zone or you will have to store the timezone settings for a user based on their selection.
You should always store your date/time values in the DB in UTC. This eliminates many conversion issues. If you store the information in UTC then you need only translate from UTC to the user's local timezone when you display the data to them and you need to convert from their time zone to UTC when you get date/time values from them.
You could use the following steps to convert the DB UTC value to the local user's time zone:
1) Get the stored timezone value for the user
2) Create a SimpleTimeZone class to wrap it
3) Use the SimpleTimeZone.ToLocalTime method to convert the DateTime value to the local time.
For converting from the user's local timezone to UTC do the reverse:
1) Get the stored timezone value from the user
2) Create a SimpleTimeZone class to wrap it
3) Use SimpleTimeZone.ToUniversalTime method to convert the DateTime to UTC.
Additionally you could check out the following forum posts which elaborates on the time zones and asp.net:
http://stackoverflow.com/questions/832986/how-to-work-with-timezone-in-asp-net
http://weblogs.asp.net/cprieto/archive/2010/01/03/handling-timezone-information-in-asp-net.aspx
I hope this helps.
Greetings,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the
Telerik Public Issue Tracking system and vote to affect the priority of the items.