DateTime.GetDateTimeFormats Method (Char)
Converts the value of this instance to all the string representations supported by the specified standard date and time format specifier.
Assembly: mscorlib (in mscorlib.dll)
A standard date and time format string (see Remarks).
Return ValueType: System.String()
A string array where each element is the representation of the value of this instance formatted with the format standard date and time format specifier.
format is not a valid standard date and time format specifier character.
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). For more information, see Standard Date and Time Format Strings.
Each element of the return value is formatted using information from the current culture. For more information about culture-specific formatting information for the current culture, see CultureInfo.CurrentCulture.
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.
The following example demonstrates themethod. It displays the string representation of a date using the long date format specifier ("D") for the current culture.
Dim july28 As Date = #7/28/2009 5:23:15# ' Get the long date formats using the current culture. Dim longJuly28Formats() As String = july28.GetDateTimeFormats("D"c) ' Display july28 in all long date formats. For Each format As String In longJuly28Formats Console.WriteLine(format) Next ' The example displays the following output: ' Tuesday, July 28, 2009 ' July 28, 2009 ' Tuesday, 28 July, 2009 ' 28 July, 2009
Available since 4.5
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Available since 8.1