Convert the specified date and time to Coordinated Universal Time (UTC) in CSharp
Description
The following code shows how to convert the specified date and time to Coordinated Universal Time (UTC).
Example
/*from w w w . j a va 2 s. c om*/
using System;
public class MainClass{
public static void Main(String[] argv){
DateTime datNowLocal = DateTime.Now;
Console.WriteLine("Converting {0}, Kind {1}:", datNowLocal, datNowLocal.Kind);
Console.WriteLine(" ConvertTimeToUtc: {0}, Kind {1}",
TimeZoneInfo.ConvertTimeToUtc(datNowLocal),
TimeZoneInfo.ConvertTimeToUtc(datNowLocal).Kind);
}
}
The code above generates the following result.