c# set datetime variable code example Example: c# set datetime var date1 = new DateTime(2008, 5, 1, 8, 30, 52); Console.WriteLine(date1);