tags:

views:

60

answers:

2

I have differents timezones and his GMT and DST. Example:

TimeZoneId GMT offset 1. Jan 2010  DST offset 1. Jul 2010
America/Adak         -10.0          -9.0
America/Anchorage     -9.0          -8.0
America/Anguilla      -4.0          -4.0
America/Antigua       -4.0          -4.0
America/Araguaina     -3.0          -3.0

This timezones are provided by Geoname.

How can I calculate the current time for any timezone knowning GMT and DST? I need the code for C#.

Update: To specify better, I provide "America/Antigua" and I need the current time in "America/Antigua".

A: 
TimeZoneInfo.ConvertTimeFromUtc(mytime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
Tesserex
A: 
       static ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();       
public static DateTime ToUsersTime(this DateTime utcDate, int timeZoneId)
        {
            return TimeZoneInfo.ConvertTimeFromUtc(utcDate, timeZones[timeZoneId]);
        }

This is an example of converting a UTC Date to a Users date using the .Net 4 TimeZoneInfo class. That may be a great place to start looking for a solution.

Simon Hazelton