DateTime::GetDateTimeFormats Method ()
Converts the value of this instance to all the string representations supported by the standard date and time format specifiers.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: array<System::String^>^A string array where each element is the representation of the value of this instance formatted with one of the standard date and time format specifiers.
The string array returned by the DateTime::GetDateTimeFormats() method is equivalent to combining the string arrays returned by separate calls to the DateTime::GetDateTimeFormats(Char) method with the "d", "D", "f", "F", "g", "G", "m", "o", "r", "s", "t", "T", "u", "U", and "y" standard format strings. For more information about standard format specifiers, 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.
Important |
|---|
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 the DateTime::GetDateTimeFormats() method. It displays the string representation of a date using all possible standard date and time formats in the computer's current culture, which in this case is en-US.
DateTime july28 = DateTime(2009, 7, 28, 5, 23, 15, 16); array<String^>^july28Formats = july28.GetDateTimeFormats(); // Print [Out] july28* in all DateTime formats using the default culture. System::Collections::IEnumerator^ myEnum = july28Formats->GetEnumerator(); while ( myEnum->MoveNext() ) { String^ format = safe_cast<String^>(myEnum->Current); System::Console::WriteLine( format ); }
The example displays the following output:
7/28/2009 7/28/09 07/28/09 07/28/2009 09/07/28 2009-07-28 28-Jul-09 Tuesday, July 28, 2009 July 28, 2009 Tuesday, 28 July, 2009 28 July, 2009 Tuesday, July 28, 2009 5:23 AM Tuesday, July 28, 2009 05:23 AM Tuesday, July 28, 2009 5:23 Tuesday, July 28, 2009 05:23 July 28, 2009 5:23 AM July 28, 2009 05:23 AM July 28, 2009 5:23 July 28, 2009 05:23 Tuesday, 28 July, 2009 5:23 AM Tuesday, 28 July, 2009 05:23 AM Tuesday, 28 July, 2009 5:23 Tuesday, 28 July, 2009 05:23 28 July, 2009 5:23 AM 28 July, 2009 05:23 AM 28 July, 2009 5:23 28 July, 2009 05:23 Tuesday, July 28, 2009 5:23:15 AM Tuesday, July 28, 2009 05:23:15 AM Tuesday, July 28, 2009 5:23:15 Tuesday, July 28, 2009 05:23:15 July 28, 2009 5:23:15 AM July 28, 2009 05:23:15 AM July 28, 2009 5:23:15 July 28, 2009 05:23:15 Tuesday, 28 July, 2009 5:23:15 AM Tuesday, 28 July, 2009 05:23:15 AM Tuesday, 28 July, 2009 5:23:15 Tuesday, 28 July, 2009 05:23:15 28 July, 2009 5:23:15 AM 28 July, 2009 05:23:15 AM 28 July, 2009 5:23:15 28 July, 2009 05:23:15 7/28/2009 5:23 AM 7/28/2009 05:23 AM 7/28/2009 5:23 7/28/2009 05:23 7/28/09 5:23 AM 7/28/09 05:23 AM 7/28/09 5:23 7/28/09 05:23 07/28/09 5:23 AM 07/28/09 05:23 AM 07/28/09 5:23 07/28/09 05:23 07/28/2009 5:23 AM 07/28/2009 05:23 AM 07/28/2009 5:23 07/28/2009 05:23 09/07/28 5:23 AM 09/07/28 05:23 AM 09/07/28 5:23 09/07/28 05:23 2009-07-28 5:23 AM 2009-07-28 05:23 AM 2009-07-28 5:23 2009-07-28 05:23 28-Jul-09 5:23 AM 28-Jul-09 05:23 AM 28-Jul-09 5:23 28-Jul-09 05:23 7/28/2009 5:23:15 AM 7/28/2009 05:23:15 AM 7/28/2009 5:23:15 7/28/2009 05:23:15 7/28/09 5:23:15 AM 7/28/09 05:23:15 AM 7/28/09 5:23:15 7/28/09 05:23:15 07/28/09 5:23:15 AM 07/28/09 05:23:15 AM 07/28/09 5:23:15 07/28/09 05:23:15 07/28/2009 5:23:15 AM 07/28/2009 05:23:15 AM 07/28/2009 5:23:15 07/28/2009 05:23:15 09/07/28 5:23:15 AM 09/07/28 05:23:15 AM 09/07/28 5:23:15 09/07/28 05:23:15 2009-07-28 5:23:15 AM 2009-07-28 05:23:15 AM 2009-07-28 5:23:15 2009-07-28 05:23:15 28-Jul-09 5:23:15 AM 28-Jul-09 05:23:15 AM 28-Jul-09 5:23:15 28-Jul-09 05:23:15 July 28 July 28 2009-07-28T05:23:15.0160000 2009-07-28T05:23:15.0160000 Tue, 28 Jul 2009 05:23:15 GMT Tue, 28 Jul 2009 05:23:15 GMT 2009-07-28T05:23:15 5:23 AM 05:23 AM 5:23 05:23 5:23:15 AM 05:23:15 AM 5:23:15 05:23:15 2009-07-28 05:23:15Z Tuesday, July 28, 2009 12:23:15 PM Tuesday, July 28, 2009 12:23:15 PM Tuesday, July 28, 2009 12:23:15 Tuesday, July 28, 2009 12:23:15 July 28, 2009 12:23:15 PM July 28, 2009 12:23:15 PM July 28, 2009 12:23:15 July 28, 2009 12:23:15 Tuesday, 28 July, 2009 12:23:15 PM Tuesday, 28 July, 2009 12:23:15 PM Tuesday, 28 July, 2009 12:23:15 Tuesday, 28 July, 2009 12:23:15 28 July, 2009 12:23:15 PM 28 July, 2009 12:23:15 PM 28 July, 2009 12:23:15 28 July, 2009 12:23:15 July, 2009 July, 2009
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
