Connecting Tech Pros Worldwide Help | Site Map

Timezones

Newbie
 
Join Date: May 2009
Posts: 16
#1: 4 Weeks Ago
Greetings to everyone

I need an advice if possible
I have to convert times between two timezones witch none of them is local.
And this have to work historically.

I tried with :
DateTime time2 = TimeZoneInfo.ConvertTime(time1, timeZone1, timeZone2);

but it seems to get confused by the local DST change and not the timeZone1 DST change.

Is there any solution ( via LINQ)

Thanks in advance
Newbie
 
Join Date: May 2009
Posts: 16
#2: 4 Weeks Ago

re: Timezones


quick example of the above tryout :


Expand|Select|Wrap|Line Numbers
  1.  private DateTime timezone_convert(DateTime time1, string zone1, string zone2) {
  2.     TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById(zone1);
  3.     TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById(zone2);
  4.  
  5.     DateTime time2 = TimeZoneInfo.ConvertTime(time1, timeZone1, timeZone2);
  6.     return time2;
  7.  
When i run the timezone_convert(time1, "Eastern Standard Time", "GMT Standard Time")

for 24/10/2009 09:30:00 and 25/10/2009 09:30:00 it returns
24/10/2009 01:30:00 and 25/10/2009 02:30:00 because locally(GMT+2) the DST changed
Reply


Similar C# / C Sharp bytes