tags:

views:

343

answers:

6

What are the best ways of dealing with UTC Conversion and daylight saving times conversion. What are the problems and their solutions. All in C# .Net 2.0. Also any existing problems with this in .Net 2.0.

+1  A: 

If you use UTC times you shouldn't worry about clients timezones or daylight saving... (if they have set a standard)

sebastian
Well in this particular case I'm converting local time into UTC. But I've read somewhere that daylight saving rules have changed recently. Sooo does the Date.ToUniversalTime() function still work correctly.
Daud
A: 

You really don't need to worry about it much with .NET if you're using UTC everywhere. If you're interested in seeing this sort of stuff in action you might check out the TimeZoneInfo class.

Brendan Enrick
A: 

I recommend standardizing all datetime entries in your app and database to UTC. Then, you can either let the users choose a preference of their timezone, which you store as an offset (eg. -5 for eastern time) or use the client machine's localization settings when displaying the time to the user.

Geoff
A: 

Don't try to figure out DST by yourself. It differs per client. You can't really assume DST rules based on timezone with all the different rules in the world. Leave that to your CLR vendor (ie Microsoft). Stick to UTC for all events (but keep in mind that midnight is time-dependent, so dates are too)

MSalters
A: 

Well in this particular case I'm converting local time into UTC. But I've read somewhere that daylight saving rules have changed recently. Sooo does the Date.ToUniversalTime() function still work correctly. Basically the dates before 2007(when the new rules came into effect) would be converted correctly but the dates after that would be not. Am I right here?

Daud
A: 

@Xardas

I think the DST times were updated in a recent patch (like a few months ago). If your system is patched you don't have to worry about it.

Luk