Learn about the various components of the DateTime object.
using System; class Program{//from w w w . j a va 2 s .c o m static void Main(string[] args) { // Current date and time (using single statement) DateTime now = DateTime.Now; // Picking up individual components int day = now.Day; int month = now.Month; int year = now.Year; int hours = now.Hour; int minutes = now.Minute; int seconds = now.Second; DateTime justDateWithoutTime = now.Date; // Output Console.WriteLine("Day: " + day); Console.WriteLine("Month: " + month); Console.WriteLine("Year: " + year); Console.WriteLine("Hours: " + hours); Console.WriteLine("Minutes: " + minutes); Console.WriteLine("Seconds: " + seconds); Console.WriteLine("Date component: " + justDateWithoutTime); // Formatting output our way Console.WriteLine("Our output: " + year + ", " + month + "/" + day + " " + hours + " hours " + minutes + " minutes"); } }