DateTime already has methods for this: ToLocalTime() and ToUniversalTime() . What is wrong with that?
EDIT:
Based on the comment that the author wants to convert to utc from a time zone other than the current time zone of computers, I refer you to John Sketsβ answer here
From the MSDN documentation :
string displayName = "(GMT+06:00) Antarctica/Mawson Time"; string standardName = "Mawson Time"; TimeSpan offset = new TimeSpan(06, 00, 00); TimeZoneInfo mawson = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName); Console.WriteLine("The current time is {0} {1}", TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, mawson), mawson.StandardName);
source share