KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using DateTime.ToLocalTime() to convert dates from UTC to local time. My time zone is GMT+1(Belgrade, Budapest, Lubjna...), it is set properly in Windows Settings (XP). Last weekend in our time zone we changed to winter time to summer time, it means, we set back local time by one hour. As I see ToLocalTime method behaves strange from that moment. When I use it to convert dates that are after this winter time change, it works great, like this: var utcDate2 = new DateTime(2011, 11, 2, 9, 0, 0,DateTimeKind.Utc); utcDate1.ToLocalTime() value is: 2011.11.02. 10:00:00 it is correct Burt when I want to convert a date before this change (e.g. a date from summer time) it gives back a bad value like this: var utcDate1 = new DateTime(2011, 10, 23, 9, 0, 0,DateTimeKind.Utc); utcDate2.ToLocalTime() value is: 2011.10.23. 10:00:00 it is incorrect It should be 2011.10.23. 11:00:00 What should I do to get correct values? How should I use ToLocalTime that also adjust winter/summer time?
Tags (comma-separated)
Save Edits
Cancel