CurrentLocalTimeForTimeZone
Returns the current local time for the specified time zone.
Source
public static DateTime CurrentLocalTimeForTimeZone(this TimeZoneInfo tzi)
{
return System.TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, tzi.Id);
}
Example
static int Main()
{
ReadOnlyCollection<TimeZoneInfo> arrTzi = TimeZoneInfo.GetSystemTimeZones();
foreach(TimeZoneInfo tzinfo in arrTzi)
{
DateTime dt = tzinfo.CurrentLocalTimeForTimeZone();
Console.Write(tzinfo.Id);
Console.Write(" ");
Console.Write(tzinfo.DisplayName);
Console.Write(" : ");
Console.WriteLine(dt.ToString("F"));
}
return 0;
}