Using the ASP.NET 3.5 framework, Convert.ToDateTime(“Tue, 08 Sep 2009 13:31:00 -0500”) returns a DateTime object with a time of 14:31. Note that I’m on the East Coast (EST -0500) so I should be seeing 13:31. I’m assuming this has to do with Daylight Saving Time (DST) not being accounted for in Convert.ToDateTime.
Is there an elegant way to correct this problem that would work across all time zones?
Is there a different date parsing method I should be aware of that would avoid this issue?
Use the DateTimeOffset structure instead:
It also has a constructor that takes a TimeSpan structure. This should respect the DST issue.
Since you mentioned timezones, another class to look into is the TimeZoneInfo class. These are both new in .NET 3.5. The example from this MSDN page returns: