C# Sortable ("s") Format
In this chapter you will learn:
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.
//from www . j a va2 s .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.
Next chapter...
What you will learn in the next chapter:
- What is a class field
- Syntax to create a new field
- A class with fields
- How to declare more than one fields
C# Standard Date Time Formatter
C# Full Date Long Time ("F") Format
C# Full Date Short Time ("f") Format
C# General Date Long Time ("G") Format
C# General Date Short Time ("g") Format
C# Long Date ("D") Format
C# Long Time ("T") Format
C# Short Date ("d") Format
C# Short Time ("t") Format
C# Month ("M", "m") Format
C# Year Month ("Y", "y") Format
C# RFC1123 ("R", "r") Format
C# Universal Full ("U") Format
C# Universal Sortable ("u") Format
C# Round-trip ("O", "o") Format
C# Full Date Long Time ("F") Format
C# Full Date Short Time ("f") Format
C# General Date Long Time ("G") Format
C# General Date Short Time ("g") Format
C# Long Date ("D") Format
C# Long Time ("T") Format
C# Short Date ("d") Format
C# Short Time ("t") Format
C# Month ("M", "m") Format
C# Year Month ("Y", "y") Format
C# RFC1123 ("R", "r") Format
C# Universal Full ("U") Format
C# Universal Sortable ("u") Format
C# Round-trip ("O", "o") Format