Export (0) Print
Expand All

DateTimeStyles Enumeration

Defines the formatting options that customize string parsing for some date and time parsing methods.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

[SerializableAttribute]
[ComVisibleAttribute(true)]
[FlagsAttribute]
public enum DateTimeStyles

Member nameDescription
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAdjustToUniversalDate and time are returned as a Coordinated Universal Time (UTC). If the input string denotes a local time, through a time zone specifier or AssumeLocal, the date and time are converted from the local time to UTC. If the input string denotes a UTC time, through a time zone specifier or AssumeUniversal, no conversion occurs. If the input string does not denote a local or UTC time, no conversion occurs and the resulting Kind property is Unspecified.

This value cannot be used with RoundtripKind.

Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAllowInnerWhiteExtra white-space characters in the middle of the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAllowLeadingWhiteLeading white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAllowTrailingWhiteTrailing white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAllowWhiteSpacesExtra white-space characters anywhere in the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns. This value is a combination of the AllowLeadingWhite, AllowTrailingWhite, and AllowInnerWhite values.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAssumeLocalIf no time zone is specified in the parsed string, the string is assumed to denote a local time.

This value cannot be used with AssumeUniversal or RoundtripKind.

Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAssumeUniversalIf no time zone is specified in the parsed string, the string is assumed to denote a UTC.

This value cannot be used with AssumeLocal or RoundtripKind.

Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsNoCurrentDateDefaultIf the parsed string contains only the time and not the date, the parsing methods assume the Gregorian date with year = 1, month = 1, and day = 1. If this value is not used, the current date is assumed.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsNoneDefault formatting options must be used. This value represents the default style for the DateTime.Parse, DateTime.ParseExact, and DateTime.TryParse methods.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsRoundtripKindThe DateTimeKind field of a date is preserved when a DateTime object is converted to a string using the "o" or "r" standard format specifier, and the string is then converted back to a DateTime object.

DateTimeStyles values can be used with any of the following date and time parsing methods that include a styles parameter to define the interpretation of the style elements that may be present in the string to be parsed:

The ParseExact and TryParseExact methods can use any of the DateTimeStyles values. However, if none of the Allow* values is selected, the input string must have exactly the same white-space characters as the format string.

If the input string does not contain any indication of the time zone, the date and time parsing methods interpret the value of the date and time string based on the time zone setting for the operating system. To convert the date and time to the Universal Time or Greenwich Mean Time (GMT), the application should use the AdjustToUniversal value. The same effect can be achieved by calling the DateTime.ToUniversalTime or DateTimeOffset.ToUniversalTime method. However, using the AdjustToUniversal value with the date and time parsing method is more efficient.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft