Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0275 DateTime Kind

Create a DateTime that differs from another only in Kind with the static DateTime.SpecifyKind method using System; using System.Text; class Sample { public static void Main() { DateTime d = new DateTime(2000, 12, 12); // Unspecified DateTime utc = DateTime.SpecifyKind(d, DateTimeKind.Utc); Console.WriteLine(utc); } } The output: 12/12/2000 12:00:00 AM