CSharp examples for System:DateTime Format
To Universal Time
using System;/*from ww w .j a va2 s .co m*/ public class Main{ public static DateTime ToUniversalTime(this DateTime localDateTime, string timeZoneId) { var date = DateTime.SpecifyKind(localDateTime, DateTimeKind.Unspecified); return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)); } public static DateTime ToUniversalTime(this DateTime localDateTime, TimeZoneInfo timeZoneInfo) { var date = DateTime.SpecifyKind(localDateTime, DateTimeKind.Unspecified); return TimeZoneInfo.ConvertTimeToUtc(date, timeZoneInfo); } }