What is Sortable ("s") Format Specifier for DateTime in C#
Description
The "s" format is defined by the DateTimeFormatInfo.SortableDateTimePattern property.
The custom format string is "yyyy'-'MM'-'dd'T'HH':'mm':'ss".
Example
The following example uses the "s" format specifier to display a DateTime and a DateTimeOffset value on a system in the U.S. Pacific Time zone.
/* ww w. j av a2s . c o m*/
using System;
class MainClass
{
public static void Main()
{
DateTime date1 = new DateTime(2012, 5, 10, 6, 30, 0);
Console.WriteLine(date1.ToString("s"));
}
}
The code above generates the following result.