|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Date and Time Format Strings
Date and time format strings control formatting operations in which a date and/or time is represented as a string. The date and time value can be represented by either a DateTime or a DateTimeOffset value.
Date and time format strings fall into two categories:
Standard date and time format strings consist of one standard date and time format specifier. Each standard format specifier denotes a particular, commonly used string representation of a date and time.
Custom date and time format strings consist of one or more custom numeric format specifiers. Combine custom date and time format specifiers to define an application-specific pattern that determines how date and time data is formatted
Date and time format strings are supported by the ToString method of the DateTime and DateTimeOffset types. Date and time 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 String.Format method, and the StringBuilder.AppendFormat method.