March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System; using System.Globalization; namespace Samples { public class DateTimeSample { public static void Main() { DateTime dt = DateTime.Now; string[] formats = {"d", "D", "f", "F", "g", "G", "m", "r", "s", "t", "T", "u", "U", "y", "dddd, MMMM dd yyyy", "ddd, MMM d \"'\"yy", "dddd, MMMM dd", "M/yy", "dd-MM-yy"}; foreach(string format in formats) { Console.WriteLine("Displayed using format {0} is: {1}", format, dt.ToString(format, DateTimeFormatInfo.InvariantInfo)); } DateTime d = new DateTime(1959, 9, 3); DateTime b = new DateTime(1973, 9, 25); Console.WriteLine("Today is {0:F}", dt); TimeSpan age = dt - d; Console.WriteLine("Damien is: {0:F}", age); Console.WriteLine("He has lived: {0,2:F} days", age.TotalDays); age = dt - b; ...Read now
Unlock full access