I was working with TimeZoneInfo class and ifound some strange stuff, following is my scenario
Time stored in UTC : {3/29/2011 11:30:00 AM}
Now when I started converting it to the user’s respective timezone with the following two methods:
TimeZoneInfo.ConvertTimeFromUtc(date,TimeZoneInfo.ConvertTimeToUtc,{(UTC-05:00) Eastern Time (US & Canada)}
Output: {3/29/2011 6:30:00 AM}
Second way:
int offset=
Convert.ToInt32(,{(UTC-05:00) Eastern Time (US & Canada)}
).BaseUtcOffset.TotalMinutes);
dateTime.AddMinutes(offset);
Output:+ {3/29/2011 7:30:00 AM}
Now as you saw there is difference between these two times, May I know why the difference is coming by doing in either way?
ConvertTimeFromUtcconsiders any adjustment rules for daylight saving time when converting, whereasBaseUtcOffsetreturns the timezone’s base offset (without any adjustment rules). If you want the UTC offset for a particular time (including any adjustment rules in effect), useGetUtcOffset.