DateTime.GetDateTimeFormats Method (Char)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Converts the value of this instance to all the string representations supported by the specified standard date and time format specifier.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

Public Function GetDateTimeFormats ( _
    format As Char _
) As String()
public string[] GetDateTimeFormats(
    char format
)

Parameters

  • format
    Type: System..::.Char
    A standard date and time format string (see Remarks).

Return Value

Type: array<System..::.String>[]()[]
A string array where each element is the representation of the value of this instance formatted with the specified standard date and time format specifier.

Exceptions

Exception Condition
FormatException

format is not a valid standard date and time format specifier character.

Remarks

The format parameter can be any of the standard date and time format specifiers. These include d, D, f, F, g, G, M (or m), O (or o), R (or r), s, t, T, u, U, and Y (or y).

Each element of the return value is formatted by using information from the current culture. For more information about culture-specific formatting information for the current culture, see CultureInfo..::.CurrentCulture.

Important Note:

Because this method uses culture-sensitive data, you should not assume that multiple calls to the method will return identical data. The data returned by this method can change if the current culture changes, the user overrides individual cultural settings, or an update occurs to the system's cultural data.

Examples

The following example demonstrates the GetDateTimeFormats(Char) method. It displays the string representation of a date using the long date format specifier ("D") for the current culture.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0

See Also

Reference

DateTime Structure

GetDateTimeFormats Overload

System Namespace