time zone & day light time
question:
how to show datetime based on user selection. if user selects JAPAN, CST,EST,PST,KOREA whichever country while login, i need to show datetime in that country timezone eventhough server is EST (eastern standard time). Please include daylight saving time. REMEMBER: user system timezone remains same eventhough he changes country.
I used following code but doesnt work for countries that use daylight saving time.
oRptDt.ToUniversalTime.AddHours(iHrs).AddMinutes(i Mins)
where oRptDt is modified date time from db, ihrs is hours to add, imins is mins to add based on timezone (country) which he selected in screen.
detailed explanation:
Our website has (Asp.net 1.1) report that shows users with last modified date time.
I have to show this time based on the timezone selected by the user when logged in. Note: This timezone is NOT BASED on the user system but based on the selection he did during login in the website because the user may select diff timezone eventhough his system time zone remains same.
for e.g. If user selected EST, in db modified date time: 08/07/2007 1:50PM for a user, I have to show it as 08/07/2007 1:50PM because server is in EST but if the user selects japan, GMT+9, i have to show this modified datetime in japan time (so convert EST to GMT and then add 9hrs to it) and if he selects PST, i have to show GMT-8 but have to include daylight time zone.
I used following code but DOESTNT work for countries which have daylight time.
oRptDt.ToUniversalTime.AddHours(iHrs).AddMinutes(i Mins)
where oRptDt is modified date time from db, ihrs is hours to add, imins is mins to add based on timezone (country) which he selected in screen.
for japan, GMT+9, hrs to add is 9, mins to add is 0.
But this line of code doesnt work for US and other countries which uses daylight timezone. for e.g. when user select PST, the time is off by 1 hr in report. any idea or help is appreciated.
|