Sortable ("s") Format Specifier in C#

CsharpProgrammingServer Side Programming

The Sortable standard format specifier represents a custom date and time format string.

The format string is defined by the DateTimeFormatInfo.SortableDateTimePattern property.

The custom format string.

yyyy'-'MM'-'dd'T'HH':'mm':'ss

Example

 Live Demo

using System;
class Demo {
   static void Main() {
      DateTime date = new DateTime(2018, 9, 5, 2, 12, 40);
      Console.WriteLine(date.ToString("s"));
   }
}

Output

2018-09-05T02:12:40
raja
Published on 14-Sep-2018 17:18:44
Advertisements