Converting from UTC to Local & Local to UTC using .NET Framework
Converting dates from or to UTC in the .NET Framework is pretty simple as the DateTime class has many built in features including many conversion related functions.
When you parse a string into a date you will need to be careful in knowing what time zone the date and time string is from but assuming you know what date time you are working with you simply use the SpecifyKind method of the DateTime class.
Example .NET Framework Date Conversion Code ( UTC / Local )
The .NET code for performing the UTC to local and back conversion is listed below.
// Get date for current moment adjusted for local time zone. DateTime utcNow = DateTime.UtcNow; DateTime localNow = DateTime.Now; // convert the UTC date to Local newDate = DateTime.SpecifyKind( utcNow, DateTimeKind.Local ); // convert the Local time to UTC newDate = DateTime.SpecifyKind( localNow, DateTimeKind.Utc );