Format time and date information 1
/* C#: The Complete Reference by Herbert Schildt Publisher: Osborne/McGraw-Hill (March 8, 2002) ISBN: 0072134852 */ // Format time and date information. using System; public class CustomTimeAndDateFormatsDemo { public static void Main() { DateTime dt = DateTime.Now; Console.WriteLine("Time is {0:hh:mm tt}", dt); Console.WriteLine("24 hour time is {0:hh:mm}", dt); Console.WriteLine("Date is {0:ddd MMM dd, yyyy}", dt); Console.WriteLine("Era: {0:gg}", dt); Console.WriteLine("Time with seconds: " + "{0:HH:mm:ss tt}", dt); Console.WriteLine("Use m for day of month: {0:m}", dt); Console.WriteLine("use m for minutes: {0:%m}", dt); } }