// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { public static TimeSpan TimeDiff(string t1, string tz1, string t2, string tz2) { TimeZoneInfo tzi1 = TimeZoneInfo.FindSystemTimeZoneById(tz1); TimeZoneInfo tzi2 = TimeZoneInfo.FindSystemTimeZoneById(tz2); DateTime dt1 = TimeZoneInfo.ConvertTimeToUtc(DateTime.Parse(t1), tzi1); DateTime dt2 = TimeZoneInfo.ConvertTimeToUtc(DateTime.Parse(t2), tzi2); return dt2 - dt1; } public static void Main(string[] args) { Console.WriteLine(TimeDiff("22-Oct-2009 20:30:00", "Eastern Standard Time", "23-Oct-2009 12:00:00", "Central Europe Standard Time")); Console.WriteLine(TimeDiff("29-Oct-2009 20:30:00", "Eastern Standard Time", "30-Oct-2009 12:00:00", "Central Europe Standard Time")); } } }