Share via


Date and Time Format StringsĀ 

DateTime format strings control formatting operations in which a date and/or time is represented as a string.

DateTime format strings fall into two categories:

  • Standard DateTime format strings.

    Standard DateTime format strings consist of one standard DateTime format specifier. Each standard format specifier denotes a particular, commonly used string representation of a date and time.

  • Custom DateTime format strings.

    Custom DateTime format strings consist of one or more custom numeric format specifiers. Combine custom DateTime format specifiers to define an application-specific pattern that determines how date and time data is formatted

DateTime format strings are supported by the ToString method of the DateTime type. DateTime format strings are also supported by the .NET Framework composite formatting feature, which is used by certain Write and WriteLine methods of the Console and StreamWriter classes, the System.String.Format method, and the System.Text.StringBuilder.AppendFormat method.

See Also

Concepts

Formatting Overview
Standard DateTime Format Strings
Custom DateTime Format Strings

Other Resources

Formatting Types