Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DateTimeStyles Enumeration

July 28, 2014

Defines the formatting options that customize string parsing for a number of DateTime and DateTimeOffset 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)

[FlagsAttribute]
public enum DateTimeStyles

Member nameDescription
AdjustToUniversalDate 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.

Cannot be used with RoundtripKind.

AllowInnerWhiteExtra white-space characters in the middle of the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
AllowLeadingWhiteLeading white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
AllowTrailingWhiteTrailing white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
AllowWhiteSpacesExtra 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.
AssumeLocalIf no time zone is specified in the parsed string, the string is assumed to denote a local time.

Cannot be used with AssumeUniversal or RoundtripKind.

AssumeUniversalIf no time zone is specified in the parsed string, the string is assumed to denote a UTC.

Cannot be used with AssumeLocal or RoundtripKind.

NoCurrentDateDefaultIf 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.
NoneDefault formatting options must be used. This value represents the default style for DateTime.Parse, DateTime.ParseExact, and DateTime.TryParse.
RoundtripKindFor parsing operations using DateTime methods on strings that contain time zone information, tries to prevent the conversion to a local DateTime value with its Kind property set to DateTimeKind.Local. For DateTimeOffset values, this flag has no effect.

The DateTimeStyles enumeration is used as a parameter that controls the parsing operation of the following methods:

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, parsing methods assume that the date and time represents the local time and either set the DateTime.Kind property to DateTimeKind.Local or set the DateTimeOffset.Offset property to the time zone offset of the local system. To convert this date and time to Coordinated Universal Time (UTC), use the AdjustToUniversal value. The same effect can be achieved using ToUniversalTime. However, using the AdjustToUniversal value is more efficient.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft