Output date and time using custom format specification
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
DateTimeOffset outputDate = new DateTimeOffset(2010, 11, 1, 9, 0, 0, new TimeSpan(-7, 0, 0));
string format = "dddd, MMM dd yyyy HH:mm:ss zzz";
Console.WriteLine(outputDate.ToString(format, null as DateTimeFormatInfo));
Console.WriteLine(outputDate.ToString(format, CultureInfo.InvariantCulture));
Console.WriteLine(outputDate.ToString(format, new CultureInfo("fr-FR")));
Console.WriteLine(outputDate.ToString(format, new CultureInfo("es-ES")));
}
}
Related examples in the same category