c# - Using TimeZoneInfo to convert between UTC/Specified TimeZone not working -


all of our date/time data in our database stored in utc time. i'm trying write function convert utc time user's preferred time zone (they can select timezone in profile has nothing local settings on computer , timezone have selected dropdown of available choices.

this function in context of devexpress aspxgridview event (the third party control not relevant question thought i'd mention it):

datetimeoffset utctime = (datetimeoffset)e.value;  timezoneinfo desttimezone = helper.gettimezoneinfo();  datetime modifieddate = timezoneinfo     .converttimefromutc(utctime.datetime, desttimezone);  e.displaytext = string.format("{0} {1}",                                modifieddate.tostring("g"),                                desttimezone.abbreviation()); 

helper.gettimezoneinfo() returns timezoneinfo class corresponds 1 user selected, or defaults "pacific standard time" if have not chosen one.

this works fine until switch system clock (which server running on) today (which oct. 14, dst date) january 11, not dst.

the time seems displayed in dst (i.e. 7 hour offset). no matter system clock, can't time adjust hour.

for example, when have timezone set pacific standard time, utc time 10-10-2011 20:00:00, always displaying time:

10-10-2011 13:00:00 (the dst time, offset of -7).

during non-daylight savings dates (standard), time should be:

10-10-2011 12:00:00 (offset of -8).

what missing?

the converted local time of utc time based on time zone info that utc time... not whatever current time happens be.

that is, pst offset on oct 10, 2011 utc always -7. doesn't matter date doing conversion on.

...or misunderstanding asking?


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -