BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.ValueType System.IComparable System.IComparable<System.DateTime> System.IConvertible System.IEquatable<System.DateTime> System.IFormattable System.Runtime.Serialization.ISerializable

The value type represents dates and times with values ranging from 00:00:00 (midnight), January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.) in the Gregorian calendar.

Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the calendar (excluding ticks that would be added by leap seconds). For example, a ticks value of 31241376000000000L represents the date, Friday, January 01, 0100 12:00:00 midnight. A value is always expressed in the context of an explicit or default calendar.

If you are working with a ticks value that you want to convert to some other time interval, such as minutes or seconds, you should use the , , , , or constant to perform the conversion. For example, to add the number of seconds represented by a specified number of ticks to the component of a value, you can use the expression dateValue.Second + nTicks/Timespan.TicksPerSecond.

In this section:

Instantiating a DateTime object
DateTime values and their string representations
Converting strings to DateTime values
Version considerations
DateTime values
DateTime operations
DateTime vs. TimeSpan
COM interop considerations

## Instantiating a DateTime object

You can create a new value in any of the following ways:

By calling any of the overloads of the constructor that allow you to specify specific elements of the date and time value (such as the year, month, and day, or the number of ticks). The following statement illustrates a call to one of the constructors to create a date with a specific year, month, day, hour, minute, and second.

code reference: System.DateTime.Instantiation#1

By using any compiler-specific syntax for declaring date and time values. For example, the following Visual Basic statement initializes a new value.

code reference: System.DateTime.Instantiation#2

By assigning the object a date and time value returned by a property or method. The following example assigns the current date and time, the current Coordinated Universal Time (UTC) date and time, and the current date to three new variables.

code reference: System.DateTime.Instantiation#3

By parsing the string representation of a date and time value. The , , , and methods all convert a string to its equivalent date and time value. The following example uses the method to parse a string and convert it to a value.

code reference: System.DateTime.Instantiation#4

Note that the and methods indicate whether a particular string contains a valid representation of a value in addition to performing the conversion.

By calling the structure's implicit default constructor. (For details on the implicit default constructor of a value type, see Value Types (C# Reference).) An approximate equivalent, for compilers that support it, is declaring a value without explicitly assigning a date and time to it. The following example illustrates a call to the implicit default constructor in C# and Visual Basic, as well as a variable declaration with no assignment in Visual Basic.

code reference: System.DateTime.Instantiation#5

## DateTime Values and their string representations

Internally, all values are represented as the number of ticks (the number of 100-nanosecond intervals) that have elapsed since 12:00:00 midnight, January 1, 0001. The actual value is independent of the way in which that value appears when displayed in a user interface element or when written to a file. The appearance of a value is the result of a formatting operation. Formatting is the process of converting a value to its string representation.

Because the appearance of date and time values is dependent on such factors as culture, international standards, application requirements, and personal preference, the structure offers a great deal of flexibility in formatting date and time values through the overloads of its method. The default method returns the string representation of a date and time value using the current culture's short date and long time pattern. The following example uses the default method to display the date and time using the short date and long time pattern for the en-US culture, the current culture on the computer on which the example was run.

code reference: System.DateTime.Formatting#1

The method returns the string representation of a date and time value using the short date and long time pattern of a specific culture. The following example uses the method to display the date and time using the short date and long time pattern for the fr-FR culture.

code reference: System.DateTime.Formatting#2

The method returns the string representation of the date and time in a format defined by a standard or custom format specifier and using the formatting conventions of the current culture. The following example uses the method to display the full date and time pattern for the en-US culture, the current culture on the computer on which the example was run.

code reference: System.DateTime.Formatting#3

The method returns the string representation of the date and time in a format defined by a specific format specifier and using the formatting conventions of a specific culture. The following example uses the method to display the full date and time pattern for the fr-FR culture.

code reference: System.DateTime.Formatting#4

For more information about formatting values, see Standard Date and Time Format Strings and Custom Date and Time Format Strings.

## Converting strings to DateTime values

Parsing involves converting the string representation of a date and time to a value. Typically, date and time strings have two different usages in applications:

They represent a date and time that can take a variety of forms and that reflect the conventions of either the current culture or a specific culture. For example, an application may allow a user whose current culture is en-US to input a date value as "12/15/2013" or "December 15, 2013", and allow a user whose current culture is en-GB to input a date value as "15/12/2013" or "15 December 2013".

They represent a date and time in a predefined format. For example, an application may serialize a date as "20130103" independently of the culture on which the app is running, or it may require that a date be input in the current culture's short date format.

You can use the or method to convert a string that might reflect one of the common date and time formats used by a culture to a value. The following example shows how you can use to convert date strings in a number of different culture-specific formats to a value. It changes the current culture to English (Great Britain) and calls the method to generate an array of date and time strings. It then passes each element in the array to the method. The output from the example shows that the parsing method was able to successfully convert each of the culture-specific date and time strings.

code reference: System.DateTime.Parsing#1

You can use the and methods to convert a date and time string that must match a particular format or formats to a value. You specify the required format or formats as a parameter to the parsing method by using one or more standard or custom date and time format strings. The following example uses the method to convert strings that must be either in a "yyyyMMdd" format or a "HHmmss" format to values.

code reference: System.DateTime.Parsing#2

The and methods throw an exception if the string to be converted to a value cannot be parsed. The and methods return a Boolean value that indicates whether the conversion succeeded or failed. Because the parsing operation for date and time strings, particularly if strings are input by users, tends to have a high failure rate, and because exception handling is expensive, you should use the or methods in scenarios where performance is important or conversions are subject to a high rate of failure.

For more information about parsing date and time values, see Parsing Date and Time Strings.

## Version considerations

Prior to the .NET Framework version 2.0, the structure contains a 64-bit field composed of an unused 2-bit field concatenated with a private Ticks field, which is a 62-bit unsigned field that contains the number of ticks that represent the date and time. The value of the Ticks field can be obtained with the property.

Starting with the .NET Framework 2.0, the structure contains a 64-bit field composed of a private Kind field concatenated with the Ticks field. The Kind field is a 2-bit field that indicates whether the structure represents a local time, a Coordinated Universal Time (UTC), or the time in an unspecified time zone. The Kind field is used when performing time conversions between time zones, but not for time comparisons or arithmetic. The value of the Kind field can be obtained with the property.

An alternative to the structure for working with date and time values in particular time zones is the structure. The structure stores date and time information in a private field and the number of minutes by which that date and time differs from UTC in a private field. This makes it possible for a value to reflect the time in a particular time zone, whereas a value can unambiguously reflect only UTC and the local time zone's time. For a discussion about when to use the structure or the structure when working with date and time values, see Choosing Between DateTime, DateTimeOffset, and TimeZoneInfo.

## DateTime values

Descriptions of time values in the type are often expressed using the Coordinated Universal Time (UTC) standard, which is the internationally recognized name for Greenwich Mean Time (GMT). Coordinated Universal Time is the time as measured at zero degrees longitude, the UTC origin point. Daylight saving time is not applicable to UTC.

Local time is relative to a particular time zone. A time zone is associated with a time zone offset, which is the displacement of the time zone measured in hours from the UTC origin point. In addition, local time is optionally affected by daylight saving time, which adds or subtracts an hour from the length of a day. Consequently, local time is calculated by adding the time zone offset to UTC and adjusting for daylight saving time if necessary. The time zone offset at the UTC origin point is zero.

UTC time is suitable for calculations, comparisons, and storing dates and time in files. Local time is appropriate for display in user interfaces of desktop applications. Time zone-aware applications (such as many Web applications) also need to work with a number of other time zones.

If the property of a object is , it is unspecified whether the time represented is local time, UTC time, or a time in some other time zone.

## DateTime operations

A calculation using a structure, such as or , does not modify the value of the structure. Instead, the calculation returns a new structure whose value is the result of the calculation.

Conversion operations between time zones (such as between UTC and local time, or between one time zone and another) take daylight saving time into account, but arithmetic and comparison operations do not.

The structure itself offers limited support for converting from one time zone to another. You can use the method to convert UTC to local time, or you can use the method to convert from local time to UTC. However, a full set of time zone conversion methods is available in the class. Using these methods, you can convert the time in any one of the world's time zones to the time in any other time zone.

Calculations and comparisons of objects are meaningful only if the objects represent times in the same time zone. You can use a object to represent a value's time zone, although the two are loosely coupled. (That is, a object does not have a property that returns an object that represents that date and time value's time zone other than the property.) For this reason, in a time zone-aware application, you must rely on some external mechanism to determine the time zone in which a object was created. For example, you could use a structure that wraps both the value and the object that represents the value's time zone. For details on using UTC in calculations and comparisons with values, see Performing Arithmetic Operations with Dates and Times.

Each member implicitly uses the Gregorian calendar to perform its operation, with the exception of constructors that specify a calendar, and methods with a parameter derived from , such as , that implicitly specifies a calendar.

Operations by members of the type take into account details such as leap years and the number of days in a month.

Two other common operations with values involve converting a date and time value to or from its string representation. The process of converting a value to its string representation is a formatting operation; for more information about formatting, see DateTime values and their string representations. The process of converting the string representation of a date and time to a value is a parsing operation; for more information about parsing, see Converting strings to DateTime values.

## DateTime vs. TimeSpan

The and value types differ in that a represents an instant in time whereas a represents a time interval. This means, for example, that you can subtract one instance of from another to obtain a object that represents the time interval between them. Or you could add a positive to the current to obtain a value that represents a future date.

You can add or subtract a time interval from a object. Time intervals can be negative or positive, can be expressed in units such as ticks or seconds, or can be expressed as a object.

## COM interop considerations

A value that is transferred to a COM application, then is transferred back to a managed application, is said to round-trip. However, a value that specifies only a time does not round-trip as you might expect.

If you round-trip only a time, such as 3 P.M., the final date and time is December 30, 1899 C.E. at 3:00 P.M., instead of January, 1, 0001 C.E. at 3:00 P.M. This happens because the .NET Framework and COM assume a default date when only a time is specified. However, the COM system assumes a base date of December 30, 1899 C.E. while the .NET Framework assumes a base date of January, 1, 0001 C.E.

When only a time is passed from the .NET Framework to COM, special processing is performed that converts the time to the format used by COM. When only a time is passed from COM to the .NET Framework, no special processing is performed because that would corrupt legitimate dates and times on or before December 30, 1899. This also means if a date starts its round-trip from COM, the .NET Framework and COM preserve the date.

The behavior of the .NET Framework and COM means that if your application round-trips a that only specifies a time, your application must remember to modify or ignore the erroneous date from the final object.

Represents an instant in time, typically expressed as a date and time of day.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  The date and time represented by is less than or greater than .

  The property is initialized to .

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  Initializes a new instance of the structure to a specified number of ticks.

  A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.
  0
- Constructor
  2.0.0.0
  4.0.0.0

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  Initializes a new instance of the structure to a specified number of ticks and to Coordinated Universal Time (UTC) or local time.

  A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.
  One of the enumeration values that indicates whether specifies a local time, Coordinated Universal Time (UTC), or neither.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  is less than 1 or greater than 9999

  -or-

  is less than 1 or greater than 12

  -or-

  is less than 1 or greater than the number of days in

  This constructor interprets , , and as a year, month, and day in the Gregorian calendar. To instantiate a value by using the year, month, and day in another calendar, call the constructor.

  The time of day for the resulting is midnight (00:00:00). The property is initialized to .

  Initializes a new instance of the structure to the specified year, month, and day.

  The year (1 through 9999).
  The month (1 through 12).
  The day (1 through the number of days in ).
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The time of day for the resulting is midnight (00:00:00). The property is initialized to .

  The allowable values for , , and depend on . An exception is thrown if the specified date and time cannot be expressed using .

  The namespace provides several calendars including and .

  Initializes a new instance of the structure to the specified year, month, and day for the specified calendar.

  The year (1 through the number of years in ).
  The month (1 through the number of months in ).
  The day (1 through the number of days in ).
  The calendar that is used to interpret , , and .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  is less than 1 or greater than 9999

  -or-

  is less than 1 or greater than 12

  -or-

  is less than 1 or greater than the number of days in

  -or-

  is less than 0 or greater than 23

  -or-

  is less than 0 or greater than 59

  -or-

  is less than 0 or greater than 59

  The property is initialized to .

  This constructor interprets , , and as a year, month, and day in the Gregorian calendar. To instantiate a value by using the year, month, and day in another calendar, call the constructor.

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, and second.

  The year (1 through 9999).
  The month (1 through 12).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  0
- Constructor
  2.0.0.0
  4.0.0.0

  This constructor interprets , , and as a year, month, and day in the Gregorian calendar. To instantiate a value by using the year, month, and day in another calendar, call the constructor.

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, and Coordinated Universal Time (UTC) or local time.

  The year (1 through 9999).
  The month (1 through 12).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  One of the enumeration values that indicates whether , , , , and specify a local time, Coordinated Universal Time (UTC), or neither.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The property is initialized to .

  The allowable values for , , and depend on . An exception is thrown if the specified date and time cannot be expressed using .

  The namespace provides several calendars including and .

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, and second for the specified calendar.

  The year (1 through the number of years in ).
  The month (1 through the number of months in ).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  The calendar that is used to interpret , , and .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  is less than 1 or greater than 9999

  -or-

  is less than 1 or greater than 12

  -or-

  is less than 1 or greater than the number of days in

  -or-

  is less than 0 or greater than 23

  -or-

  is less than 0 or greater than 59

  -or-

  is less than 0 or greater than 59

  -or-

  is less than 0 or greater than 999

  The specified parameters evaluate to a date less than or greater than .

  This constructor interprets , , and as a year, month, and day in the Gregorian calendar. To instantiate a value by using the year, month, and day in another calendar, call the constructor.

  The property is initialized to .

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, and millisecond.

  The year (1 through 9999).
  The month (1 through 12).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  The milliseconds (0 through 999).
  0
- Constructor
  2.0.0.0
  4.0.0.0

  This constructor interprets , , and as a year, month, and day in the Gregorian calendar. To instantiate a value by using the year, month, and day in another calendar, call the constructor.

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time.

  The year (1 through 9999).
  The month (1 through 12).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  The milliseconds (0 through 999).
  One of the enumeration values that indicates whether , , , , , , and specify a local time, Coordinated Universal Time (UTC), or neither.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The property is initialized to .

  The allowable values for , , and depend on . An exception is thrown if the specified date and time cannot be expressed using .

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  The namespace provides several calendars including and .

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, and millisecond for the specified calendar.

  The year (1 through the number of years in ).
  The month (1 through the number of months in ).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  The milliseconds (0 through 999).
  The calendar that is used to interpret , , and .
- Constructor
  2.0.0.0
  4.0.0.0

  The allowable values for , , and parameters depend on the parameter. An exception is thrown if the specified date and time cannot be expressed using .

  For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor.

  The namespace provides several calendars including and .

  Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time for the specified calendar.

  The year (1 through the number of years in ).
  The month (1 through the number of months in ).
  The day (1 through the number of days in ).
  The hours (0 through 23).
  The minutes (0 through 59).
  The seconds (0 through 59).
  The milliseconds (0 through 999).
  The calendar that is used to interpret , , and .
  One of the enumeration values that indicates whether , , , , , , and specify a local time, Coordinated Universal Time (UTC), or neither.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  You can use the method to add more than one kind of time interval (days, hours, minutes, seconds, or milliseconds) in a single operation. This method's behavior is identical to that of the addition operator. The structure also supports specialized addition methods (such as , , and ) for each time interval.

  The method takes into account leap years and the number of days in a month when performing date arithmetic.

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation. The property of the new instance is the same as that of the current instance.

  Returns a new that adds the value of the specified to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the time interval represented by .

  A positive or negative time interval. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation.

  The fractional part of is the fractional part of a day. For example, 4.5 is equivalent to 4 days, 12 hours, 0 minutes, 0 seconds, 0 milliseconds, and 0 ticks.

  The parameter is rounded to the nearest millisecond.

  Returns a new that adds the specified number of days to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the number of days represented by .

  A number of whole and fractional days. The parameter can be negative or positive. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation. The property of the returned object is the same as that of .

  The fractional part of is the fractional part of an hour. For example, 4.5 is equivalent to 4 hours, 30 minutes, 0 seconds, 0 milliseconds, and 0 ticks.

  The parameter is rounded to the nearest millisecond.

  Converting time intervals of less than an hour to a fraction can involve a loss of precision if the result is a non-terminating repeating decimal. (For example, one minute is 0.016667 of an hour.) If this is problematic, you can use the method, which enables you to specify more than one kind of time interval in a single method call and eliminates the need to convert time intervals to fractional parts of an hour.

  Returns a new that adds the specified number of hours to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the number of hours represented by .

  A number of whole and fractional hours. The parameter can be negative or positive. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation.

  The fractional part of is the fractional part of a millisecond. For example, 4.5 is equivalent to 4 milliseconds and 5000 ticks, where one millisecond = 10000 ticks.

  The parameter is rounded to the nearest integer.

  Returns a new that adds the specified number of milliseconds to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the number of milliseconds represented by .

  A number of whole and fractional milliseconds. The parameter can be negative or positive. Note that this value is rounded to the nearest integer. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation.

  The fractional part of is the fractional part of a minute. For example, 4.5 is equivalent to 4 minutes, 30 seconds, 0 milliseconds, and 0 ticks.

  The parameter is rounded to the nearest millisecond.

  Returns a new that adds the specified number of minutes to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the number of minutes represented by .

  A number of whole and fractional minutes. The parameter can be negative or positive. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime ``

  The resulting is less than or greater than .

  -or-

  The parameter is less than -120,000 or greater than 120,000

  This method does not change the value of this object. Instead, it returns a new object whose value is the result of this operation.

  The method calculates the resulting month and year, taking into account leap years and the number of days in a month, then adjusts the day part of the resulting object. If the resulting day is not a valid day in the resulting month, the last valid day of the resulting month is used. For example, March 31st + 1 month = April 30th. The time-of-day part of the resulting object remains the same as this instance.

  Returns a new that adds the specified number of months to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and .

  A number of months. The parameter can be negative or positive. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation.

  The fractional part of is the fractional part of a second. For example, 4.5 is equivalent to 4 seconds, 500 milliseconds, and 0 ticks.

  The parameter is rounded to the nearest millisecond.

  Returns a new that adds the specified number of seconds to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the number of seconds represented by .

  A number of whole and fractional seconds. The parameter can be negative or positive. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation.

  Returns a new that adds the specified number of ticks to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the time represented by .

  A number of 100-nanosecond ticks. The parameter can be positive or negative. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting is less than or greater than .

  This method does not change the value of this object. Instead, it returns a new object whose value is the result of this operation.

  The method calculates the resulting year taking into account leap years. The month and time-of-day part of the resulting object remains the same as this instance.

  If the current instance represents the leap day in a leap year, the return value depends on the target date:

  If + is also a leap year, the return value represents the leap day in that year. For example, if four years is added to February 29, 2012, the date returned is February 29, 2016.

  If + is not a leap year, the return value represents the day before the leap day in that year. For example, if one year is added to February 29, 2012, the date returned is February 28, 2013.

  The following example illustrates using the method with a value that represents a leap year day. It displays the date for the fifteen years prior to and the fifteen years that follow February 29, 2000.

  code reference: System.DateTime.AddYears#1

  Returns a new that adds the specified number of years to the value of this instance.

  An object whose value is the sum of the date and time represented by this instance and the number of years represented by .

  A number of years. The parameter can be negative or positive. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` ``

  Before comparing objects, ensure that the objects represent times in the same time zone.

  Compares two instances of and returns an integer that indicates whether the first instance is earlier than, the same as, or later than the second instance.

  A signed number indicating the relative values of and .

  Value Type

  Condition

  Less than zero

  is earlier than .

  Zero

  is the same as .

  Greater than zero

  is later than .

  The first object to compare. The second object to compare. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method implements the interface and performs slightly better than the method overload because it does not have to convert the parameter to an object.

  Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their properties.

  Compares the value of this instance to a specified value and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified value.

  A signed number indicating the relative values of this instance and the parameter.

  Value

  Description

  Less than zero

  This instance is earlier than .

  Zero

  This instance is the same as .

  Greater than zero

  This instance is later than .

  The object to compare to the current instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is not a and is not a null reference.

  Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their properties.

  Any instance of , regardless of its value, is considered greater than null.

  Compares the value of this instance to a specified object that contains a specified value, and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified value.

  A signed number indicating the relative values of this instance and .

  Value

  Description

  Less than zero

  This instance is earlier than .

  Zero

  This instance is the same as .

  Greater than zero

  This instance is later than , or is null.

  A boxed object to compare, or null. 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime

  A new instance with the same date as the current instance, and the time value set to midnight (00:00:00).

  The value of the property of the returned value is the same as that of the current instance.

  Because the type represents both dates and times in a single type, it is important to avoid misinterpreting a date returned by the property as a date and time. For more information, see "Saving and Restoring DateTime Values" in the topic.

  Gets the date component of this instance.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 1 and 31 set to the day of the month component of the current instance.

  The property always returns the day of the month in the Gregorian calendar, even if the current value was instantiated using some other calendar or if the current thread culture's default calendar is not the Gregorian calendar. To retrieve the day of the month of a particular date using some other calendar, call that calendar's method. The following example uses both the property and the method to retrieve the day of the month for a value that is instantiated using the Hijri calendar.

  code reference: System.DateTime.Day#1

  Similarly, the following example uses both the property and the method to retrieve the day of the month when the current thread culture is ar-SA, which uses Hijri as its default calendar.

  code reference: System.DateTime.Day#2

  Gets the day of the month represented by this instance.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DayOfWeek To be added.

  The value of the constants in the enumeration ranges from to . If cast to an integer, its value ranges from zero (which indicates ) to six (which indicates ).

  The property returns an enumerated constant; it does not reflect a system's regional and language settings. To retrieve a string representing a localized weekday name for a particular date, call one of the overloads of the method that includes a parameter and pass it either the ddd or dddd custom format strings. For details, see How to: Extract the Day of the Week from a Specific Date.

  Gets the day of the week represented by this instance.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 1 and 366 set to the day of the year component of the current instance.

  The property takes leap years into account when it calculates the day of the year. The property value always reflects the day of the year in the Gregorian calendar, regardless of the current thread culture's current calendar. To retrieve the day of the year in a different calendar, call the method of that calendar.

  Gets the day of the year represented by this instance.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` is less than 1 or greater than 12.

  The method always interprets and as the month and year of the Gregorian calendar even if the Gregorian calendar is not the current culture's current calendar. To get the number of days in a specified month of a particular calendar, call that calendar's method.

  Returns the number of days in the specified month and year.

  The number of days in for the specified .

  For example, if equals 2 for February, the return value is 28 or 29 depending upon whether is a leap year.

  The year. The month (a number ranging from 1 to 12). 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The current instance and are equal if their property values are equal. Their property values are not considered in the test for equality.

  This method implements the interface, and performs slightly better than the method because the parameter does not have to be converted to an object.

  Returns a value indicating whether the value of this instance is equal to the value of the specified instance.

  true if the parameter equals the value of this instance; otherwise, false.

  The object to compare to this instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The current instance and are equal if their property values are equal. Their property values are not considered in the test for equality.

  Returns a value indicating whether this instance is equal to a specified object.

  true if is an instance of and equals the value of this instance; otherwise, false.

  The object to compare to this instance. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  and are equal if their property values are equal. Their property values are not considered in the test for equality.

  Returns a value indicating whether two instances have the same date and time value.

  true if the two values are equal; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  2.0.0.0
  4.0.0.0
  System.DateTime ``

  Use the method to convert the value of the current object to a binary value. Subsequently, use the binary value and the method to recreate the original object.

  In some cases, the value returned by the method is not identical to the original value supplied to the method. For more information, see the next section, "Local Time Adjustment".

  ## Local Time Adjustment

  A local time, which is a Coordinated Universal Time adjusted to the local time zone, is represented by a structure whose property has the value . When restoring a local value from the binary representation that is produced by the method, the method may adjust the recreated value so that it is not equal to the original value. This can occur under the following conditions:

  If a local object is serialized in one time zone by the method, and then deserialized in a different time zone by the method, the local time represented by the resulting object is automatically adjusted to the second time zone.

  For example, consider a object that represents a local time of 3 P.M. An application that is executing in the U.S. Pacific Time zone uses the method to convert that object to a binary value. Another application that is executing in the U.S. Eastern Time zone then uses the method to convert the binary value to a new object. The value of the new object is 6 P.M., which represents the same point in time as the original 3 P.M. value, but is adjusted to local time in the Eastern Time zone.

  If the binary representation of a local value represents an invalid time in the local time zone of the system on which is called, the time is adjusted so that it is valid.

  For example, the transition from standard time to daylight saving time occurs in the Pacific Time zone of the United States on March 14, 2010, at 2:00 A.M., when the time advances by one hour, to 3:00 A.M. This hour interval is an invalid time, that is, a time interval that does not exist in this time zone. The following example shows that when a time that falls within this range is converted to a binary value by the method and is then restored by the method, the original value is adjusted to become a valid time. You can determine whether a particular date and time value may be subject to modification by passing it to the method, as the example illustrates.

  code reference: System.DateTime.FromBinary#1

  ## Version Considerations

  Starting with the .NET Framework version 2.0, a structure consists of a private Kind field, which indicates whether the specified time is local time, Coordinated Universal Time (UTC), or neither, concatenated to a private Ticks field, which contains the number of 100-nanosecond ticks that specify a date and time. The number of ticks can be accessed with the property and the Kind field can be accessed with the property.

  Prior to the .NET Framework 2.0, if you serialized a object manually instead of using a serialization interface such as , you needed to serialize only the Ticks data in the . Starting with the .NET Framework 2.0, you must also serialize the Kind data.

  Deserializes a 64-bit binary value and recreates an original serialized object.

  An object that is equivalent to the object that was serialized by the method.

  A 64-bit signed integer that encodes the property in a 2-bit field and the property in a 62-bit field.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime ``

  A Windows file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC). Windows uses a file time to record when an application creates, accesses, or writes to a file.

  The parameter specifies a file time expressed in 100-nanosecond ticks.

  Starting with the .NET Framework version 2.0, the return value is a whose property is .

  Converts the specified Windows file time to an equivalent local time.

  An object that represents the local time equivalent of the date and time represented by the parameter.

  A Windows file time expressed in ticks.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime ``

  A Windows file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC). Windows uses a file time to record when an application creates, accesses, or writes to a file.

  The parameter specifies a file time expressed in 100-nanosecond ticks.

  Starting with the .NET Framework version 2.0, the return value is a whose property is .

  Converts the specified Windows file time to an equivalent UTC time.

  An object that represents the UTC time equivalent of the date and time represented by the parameter.

  A Windows file time expressed in ticks.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime ``

  The parameter is a double-precision floating-point number that represents a date as the number of days before or after the base date, midnight, 30 December 1899. The sign and integral part of encode the date as a positive or negative day displacement from 30 December 1899, and the absolute value of the fractional part of encodes the time of day as a fraction of a day displacement from midnight. must be a value between negative 657435.0 through positive 2958465.99999999.

  Note that because of the way dates are encoded, there are two ways of representing any time of day on 30 December 1899. For example, -0.5 and 0.5 both mean noon on 30 December 1899 because a day displacement of plus or minus zero days from the base date is still the base date, and a half day displacement from midnight is noon.

  See and the MSDN Online Library at http://MSDN.Microsoft.com/library/default.asp for more information on OLE Automation.

  Returns a equivalent to the specified OLE Automation Date.

  An object that represents the same date and time as .

  An OLE Automation Date value.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String[]

  The string array returned by the method is equivalent to combining the string arrays returned by separate calls to the 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 .

  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.

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

  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.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String[] ``

  The 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 .

  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.

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

  A string array where each element is the representation of the value of this instance formatted with the standard date and time format specifier.

  A standard date and time format string (see Remarks).
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String[] ``

  The string array returned by the method is equivalent to combining the string arrays returned by separate calls to the 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 culture-specific information supplied by .

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

  Converts the value of this instance to all the string representations supported by the standard date and time format specifiers and the specified culture-specific formatting information.

  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.

  An object that supplies culture-specific formatting information about this instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String[] `` ``

  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 culture-specific information supplied by .

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

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

  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.

  A date and time format string (see Remarks). An object that supplies culture-specific formatting information about this instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  The algorithm used to generate the hash code is unspecified.

  This method overrides .

  Returns the hash code for this instance.

  A 32-bit signed integer hash code.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TypeCode To be added.

  Returns the for value type .

  The enumerated constant, .

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 23 set to the hour component of the current instance.

  The value of the property is always expressed using a 24-hour clock. To retrieve a string that represents the hour of a date and time using a 12-hour clock, call the or method with the "h" custom format specifier. For example:

  code reference: System.DateTime.Hour#1

  Gets the hour component of the date represented by this instance.

  0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean

  This method determines whether the current value falls within the daylight saving time range of the local time zone, which is returned by the property. You can determine whether a time zone supports daylight saving time by retrieving the value of its property. For time zones that observe daylight saving time, you can determine when the transition to and from daylight saving time occurs by retrieving the array returned by the time zone's property.

  If the current value represents either an ambiguous or an invalid time in the local time zone, the method returns false.

  On winxp systems, the method recognizes only the current adjustment rule when determining whether the current instance is a daylight saving time. As a result, the method may not accurately report whether the current instance is a daylight saving time for periods before the current adjustment rule came into effect.

  Indicates whether this instance of is within the daylight saving time range for the current time zone.

  true if the value of the property is or and the value of this instance of is within the daylight saving time range for the local time zone; false if is .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  is specified as a 4-digit base 10 number; for example, 1996.

  is always interpreted as a year in the Gregorian calendar. To determine whether a particular year was a leap year in some other calendar, call that calendar object's IsLeapYear method.

  Returns an indication whether the specified year is a leap year.

  true if is a leap year; otherwise, false.

  A 4-digit year. 0
- Property
  2.0.0.0
  4.0.0.0
  System.DateTimeKind To be added.

  You can explicitly set the property of a new value to a particular value by calling the method.

  The property allows a value to clearly reflect either Coordinated Universal Time (UTC) or the local time. In contrast, the structure can unambiguously reflect any time in any time zone as a single point in time.

  Gets a value that indicates whether the time represented by this instance is based on local time, Coordinated Universal Time (UTC), or neither.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime 12/31/9999 11:59:59 PM

  The value of this constant is equivalent to 23:59:59.9999999, December 31, 9999, exactly one 100-nanosecond tick before 00:00:00, January 1, 10000.

  Some calendars, such as the , support an upper date range that is earlier than . In these cases, trying to access in variable assignments or formatting and parsing operations can throw an . Rather than retrieving the value of , you can retrieve the value of the specified culture's latest valid date value from the System.Globalization.CultureInfo.DateTimeFormat.Calendar.MaxSupportedDateTime property.

  Represents the largest possible value of . This field is read-only.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 999 set to the milliseconds component of the current instance.

  You can display the string representation of the property by using the "fff" format specifier. For example, the following code displays a string that contains the number of milliseconds in a date and time to the console.

  code reference: System.DateTime.Millisecond#1

  You can also display the millisecond component together with the other components of a date and time value by using the "o" standard format specifier. For example:

  code reference: System.DateTime.Millisecond#2

  However, the "o" format specifier is intended less for displaying than for round-tripping or storing a value. You can also display milliseconds together with other date and time components by using a custom format string, as the following example shows.

  code reference: System.DateTime.Millisecond#3

  Gets the milliseconds component of the date represented by this instance.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 59 set to the minute component of the current instance.

  This property is read-only.

  Gets the minute component of the date represented by this instance.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime 1/1/0001 12:00:00 AM

  The value of this constant is equivalent to 00:00:00.0000000, January 1, 0001.

  defines the date and time that is assigned to an uninitialized variable. The following example illustrates this.

  code reference: System.DateTime.MinValue#1

  The and properties can be used to ensure that a value lies within the supported range before passing it to a constructor. The code in the Example section illustrates this usage.

  Represents the smallest possible value of . This field is read-only.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 1 and 12 set to the month component of the current instance.

  This property is read-only.

  Gets the month component of the date represented by this instance.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime To be added.

  The resolution of this property depends on the system timer.

  System

  Approximate Resolution

  Windows NT 3.5 and later

  10 milliseconds

  Windows 98

  55 milliseconds

  The property is frequently used to measure performance. However, because of its low resolution, it is not suitable for use as a benchmarking tool. A better alternative is to use the class.

  Starting with the .NET Framework version 2.0, the return value is a whose property returns .

  You can also use the property to retrieve the current local date and time. It allows a local time to be expressed unambiguously as a single point in time, which in turn makes that time value portable across computers.

  Gets a object that is set to the current date and time on this computer, expressed as the local time.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` ``

  The returned value is equivalent to ( .Ticks + .Ticks ).

  The resulting date and time is less than or greater than .

  Adds a specified time interval to a specified date and time, yielding a new date and time.

  An object that is the sum of the values of and .

  The date and time value to add. The time interval to add. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The operator determines whether two values are equal by comparing their number of ticks. Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their property.

  Determines whether two specified instances of are equal.

  true if and represent the same date and time; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The operator determines the relationship between two values by comparing their number of ticks. Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their property.

  Determines whether one specified is later than another specified .

  true if is later than ; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The operator determines the relationship between two values by comparing their number of ticks. Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their property.

  Determines whether one specified represents a date and time that is the same as or later than another specified .

  true if is the same as or later than ; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The operator determines whether two values are not equal by comparing their number of ticks. Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their property.

  Determines whether two specified instances of are not equal.

  true if and do not represent the same date and time; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The operator determines the relationship between two values by comparing their number of ticks. Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their property.

  Determines whether one specified is earlier than another specified .

  true if is earlier than ; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The operator determines the relationship between two values by comparing their number of ticks. Before comparing objects, make sure that the objects represent times in the same time zone. You can do this by comparing the values of their property.

  Determines whether one specified represents a date and time that is the same as or earlier than another specified .

  true if is the same as or later than ; otherwise, false.

  The first object to compare. The second object to compare. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan `` `` The resulting date and time is less than or greater than .

  The method does not consider the value of the property of the two values when performing the subtraction. Before subtracting objects, ensure that the objects represent times in the same time zone. Otherwise, the result will include the difference between time zones.

  The method does consider the difference between time zones when performing the subtraction.

  Subtracts a specified date and time from another specified date and time and returns a time interval.

  The time interval between and ; that is, minus .

  The date and time value to subtract from (the minuend). The date and time value to subtract (the subtrahend). 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` `` The resulting date and time is less than or greater than .

  This method subtracts the ticks value of from the ticks value of .

  Subtracts a specified time interval from a specified date and time and returns a new date and time.

  An object whose value is the value of minus the value of .

  The date and time value to subtract from. The time interval to subtract. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` is a null reference. does not contain a valid string representation of a time or date and time.

  For examples and comprehensive usage information about this and other overloads of the Parse method, see the overload summary.

  Converts the string representation of a date and time to its equivalent.

  An object that is equivalent to the date and time contained in .

  A string that contains a date and time to convert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` `` is a null reference. does not contain a valid string representation of a time or date and time.

  For examples and comprehensive usage information about this and other overloads of the Parse method, see the overload summary.

  Converts the string representation of a date and time to its equivalent by using culture-specific format information.

  An object that is equivalent to the date and time contained in as specified by .

  A string that contains a date and time to convert. An object that supplies culture-specific format information about . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` `` `` is a null reference. does not contain a valid string representation of a time or date and time. A bitwise combination of the enumeration values that indicates the style elements that can be present in for the parse operation to succeed, and that defines how to interpret the parsed date in relation to the current time zone or the current date. A typical value to specify is .

  For examples and comprehensive usage information about this and other overloads of the Parse method, see the overload summary.

  Converts the string representation of a date and time to its equivalent by using culture-specific format information and formatting style.

  An object that is equivalent to the date and time contained in , as specified by and .

  A string that contains a date and time to convert. An object that supplies culture-specific formatting information about . A bitwise combination of the enumeration values that indicates the style elements that can be present in for the parse operation to succeed, and that defines how to interpret the parsed date in relation to the current time zone or the current date. A typical value to specify is . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` `` `` or is a null reference.

  or is an empty string.

  -or-

  does not contain a date and time that were recognized as the pattern specified in .

  This example demonstrates the method.

  `using System; using System.Globalization; public class DateTimeTest { public static void Main() { DateTimeFormatInfo dtfi = new DateTimeFormatInfo(); DateTime dt = DateTime.ParseExact("January 22", dtfi.MonthDayPattern, null); Console.WriteLine(dt); } }`

  The output is

  1/22/2001 12:00:00 AM

  The method parses the string representation of a date, which must be in the format defined by the parameter. It also requires that the <Date> and <Time> elements of the string representation of a date and time appear in the order specified by , and that have no white space other than that permitted by . If defines a date with no time element and the parse operation succeeds, the resulting value has a time of midnight (00:00:00). If defines a time with no date element and the parse operation succeeds, the resulting value has a date of DateTime.Now.Date.

  If does not represent a time in a particular time zone and the parse operation succeeds, the property of the returned value is . If does represent the time in a particular time zone and allows time zone information to be present (for example, if is equal to the "o", "r", or "u" standard format specifiers, or if it contains the "z", "zz", or "zzz" custom format specifiers), the property of the returned value is .

  The parameter is a string that contains either a single standard format specifier, or one or more custom format specifiers that define the required format of . For details about valid formatting codes, see Standard DateTime Format Strings or Custom DateTime Format Strings.

  If is a custom format pattern that does not include date or time separators (such as "yyyyMMdd HHmm"), use the invariant culture for the parameter and the widest form of each custom format specifier. For example, if you want to specify hours in the format pattern, specify the wider form, "HH", instead of the narrower form, "H".

  The particular date and time symbols and strings (such as names of the days of the week in a particular language) used in are defined by the parameter, as is the precise format of if is a standard format specifier string. The parameter can be any of the following:

  A object that represents the culture used to interpret . The object returned by its property defines the symbols and formatting in .

  A object that defines the format of date and time data.

  A custom implementation whose method returns either the object or the object that provides formatting information.

  If is null, the object that corresponds to the current culture is used.

  Converts the specified string representation of a date and time to its equivalent using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly.

  An object that is equivalent to the date and time contained in , as specified by and .

  A string that contains a date and time to convert. A format specifier that defines the required format of . For more information, see the Remarks section. An object that supplies culture-specific format information about . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` `` `` `` or is a null reference.

  or format is an empty string.

  -or-

  does not contain a date and time that were recognized as one of the patterns specified in

  This example demonstrates the method.

  `using System; using System.Globalization; public class DateTimeTest { public static void Main() { DateTimeFormatInfo dtfi = new DateTimeFormatInfo(); DateTime dt = DateTime.ParseExact(" January 22 ", dtfi.MonthDayPattern, null, DateTimeStyles.AllowWhiteSpaces); Console.WriteLine(dt); } }`

  The output is

  1/22/2001 12:00:00 AM

  The method parses the string representation of a date, which must be in a format defined by the parameter. It also requires that the date and time elements in appear in the order specified by . If does not match the pattern of the parameter, with any variations defined by the parameter, the method throws a . In contrast, the method parses the string representation of a date in any one of the formats recognized by the format provider's object. The method also allows the date and time elements in to appear in any order.

  If the parameter contains only a time and no date, the current date is used unless the parameter includes the flag, in which case the default date (DateTime.Date.MinValue) is used. If the parameter contains only a date and no time, midnight (00:00:00) is used. The parameter also determines whether the parameter can contain leading, inner, or trailing white space characters.

  If contains no time zone information, the property of the returned object is . This behavior can be changed by using the flag, which returns a value whose property is , or by using the and flags, which returns a value whose property is . If contains time zone information, the time is converted to local time, if necessary, and the property of the returned object is set to . This behavior can be changed by using the flag to not convert Coordinated Universal Time (UTC) to a local time and to set the property to .

  The parameter defines the required pattern of the parameter. It can consist of either one or more custom format specifiers from the Custom DateTime Format Strings table, or a single standard format specifier, which identifies a predefined pattern, from the Standard DateTime Format Strings table.

  If you do not use date or time separators in a custom format pattern, use the invariant culture for the parameter and the widest form of each custom format specifier. For example, if you want to specify hours in the pattern, specify the wider form, "HH", instead of the narrower form, "H".

  Rather than requiring that conform to a single format for the parse operation to succeed, you can call the method and specify multiple permitted formats. This makes the parse operation more likely to succeed.

  The parameter includes one or more members of the enumeration that determine whether and where white space not defined by can appear in and that control the precise behavior of the parse operation. The following table describes how each member of the enumeration affects the operation of the method.

  DateTimeStyles member

  Description

  Parses and, if necessary, converts it to UTC. If includes a time zone offset, or if contains no time zone information but includes the flag, the method parses the string, calls to convert the returned value to UTC, and sets the property to . If indicates that it represents UTC, or if does not contain time zone information but includes the flag, the method parses the string, performs no time zone conversion on the returned value, and sets the property to . In all other cases, the flag has no effect.

  Specifies that white space not defined by can appear between any individual date or time element.

  Specifies that white space not defined by can appear at the beginning of .

  Specifies that white space not defined by can appear at the end of .

  Specifies that may contain leading, inner, and trailing white spaces not defined by .

  Specifies that if lacks any time zone information, it is assumed to represent a local time. Unless the flag is present, the property of the returned value is set to .

  Specifies that if lacks any time zone information, it is assumed to represent UTC. Unless the flag is present, the method converts the returned value from UTC to local time and sets its property to .

  If contains time without date information, the date of the return value is set to DateTime.MinValue.Date.

  The parameter is parsed using default values. No white space other than that present in is allowed. If lacks a date component, the date of the returned value is set to 1/1/0001. If contains no time zone information, the property of the returned object is set to . If time zone information is present in , the time is converted to local time and the property of the returned object is set to .

  For strings that contain time zone information, tries to prevent the conversion to a value date and time with its property set to . This flag primarily prevents the conversion of UTC times to local times.

  The particular date and time symbols and strings (such as the names of the days of the week in a particular language) used in are defined by the parameter, as is the precise format of if is a standard format specifier string. The parameter can be any of the following:

  A object that represents the culture used to interpret . The object returned by its property defines the symbols and formatting in .

  A object that defines the format of date and time data.

  A custom implementation whose method returns either the object or the object that provides formatting information.

  If is null, the object that corresponds to the current culture is used.

  Converts the specified string representation of a date and time to its equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly or an exception is thrown.

  An object that is equivalent to the date and time contained in , as specified by , , and .

  A string containing a date and time to convert. A format specifier that defines the required format of . For more information, see the Remarks section. An object that supplies culture-specific formatting information about . A bitwise combination of the enumeration values that provides additional information about , about style elements that may be present in , or about the conversion from to a value. A typical value to specify is . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` `` `` `` or is a null reference.

  or is an empty string.

  -or-

  does not contain a date and time that were recognized as the pattern specified in

  This example demonstrates the method.

  `using System; using System.Globalization; public class DateTimeTest { public static void Main() { DateTimeFormatInfo dtfi = new DateTimeFormatInfo(); string [] patterns = {dtfi.LongTimePattern, dtfi.ShortTimePattern}; DateTime dt = DateTime.ParseExact("10:11:12", patterns, null, DateTimeStyles.NoCurrentDateDefault); Console.WriteLine(dt); } }`

  The output is

  1/1/0001 10:11:12 AM

  The method parses the string representation of a date that matches any one of the patterns assigned to the parameter. If the string does not match any one of these patterns with any of the variations defined by the parameter, the method throws a . Aside from comparing to multiple formatting patterns, rather than to a single formatting pattern, this overload behaves identically to the method.

  The parameter contains the date and time to parse. If the parameter contains only a time and no date, the current date is used unless the parameter includes the flag, in which case the default date (DateTime.Date.MinValue) is used. If the parameter contains only a date and no time, midnight (00:00:00) is used. The parameter also determines whether the parameter can contain leading, inner, or trailing white space characters other than those permitted by one of the format strings in .

  If contains no time zone information, the property of the returned object is . This behavior can be changed by using the flag, which returns a value whose property is , or by using the and flags, which returns a value whose property is . If contains time zone information, the time is converted to local time, if necessary, and the property of the returned object is set to . This behavior can be changed by using the flag to not convert Coordinated Universal Time (UTC) to a local time and set the property to .

  The parameter contains an array of patterns, one of which must match exactly if the parse operation is to succeed. The patterns in the parameter consists of one or more custom format specifiers from the Custom DateTime Format Strings table, or a single standard format specifier, which identifies a predefined pattern, from the Standard DateTime Format Strings table.

  If you do not use date or time separators in a custom format pattern, use the invariant culture for the parameter and the widest form of each custom format specifier. For example, if you want to specify hours in the pattern, specify the wider form, "HH", instead of the narrower form, "H".

  The parameter includes one or more members of the enumeration that determine whether and where white space not defined by can appear in and that control the precise behavior of the parse operation. The following table describes how each member of the enumeration affects the operation of the method.

  DateTimeStyles member

  Description

  Parses and, if necessary, converts it to UTC. If includes a time zone offset, or if contains no time zone information but includes the flag, the method parses the string, calls to convert the returned value to UTC, and sets the property to . If indicates that it represents UTC, or if does not contain time zone information but includes the flag, the method parses the string, performs no time zone conversion on the returned value, and sets the property to . In all other cases, the flag has no effect.

  Specifies that white space not defined by can appear between any individual date or time element.

  Specifies that white space not defined by can appear at the beginning of .

  Specifies that white space not defined by can appear at the end of .

  Specifies that may contain leading, inner, and trailing white spaces not defined by .

  Specifies that if lacks any time zone information, it is assumed to represent a local time. Unless the flag is present, the property of the returned value is set to .

  Specifies that if lacks any time zone information, it is assumed to represent UTC. Unless the flag is present, the method converts the returned value from UTC to local time and sets its property to .

  If contains time without date information, the date of the return value is set to DateTime.MinValue.Date.

  The parameter is parsed using default values. No white space other than that present in is allowed. If lacks a date component, the date of the returned value is set to 1/1/0001. If contains no time zone information, the property of the returned object is set to . If time zone information is present in , the time is converted to local time and the property of the returned object is set to .

  For strings that contain time zone information, tries to prevent the conversion to a date and time with its property set to . This flag primarily prevents the conversion of UTC times to local times.

  The particular date and time symbols and strings (such as the names of the days of the week in a particular language) used in are defined by the parameter, as is the precise format of if is a standard format specifier string. The parameter can be any of the following:

  A object that represents the culture used to interpret . The object returned by its property defines the symbols and formatting in .

  A object that defines the format of date and time data.

  A custom implementation whose method returns either the object or the object that provides formatting information.

  If is null, the object that corresponds to the current culture is used.

  Converts the specified string representation of a date and time to its equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match at least one of the specified formats exactly or an exception is thrown.

  An object that is equivalent to the date and time contained in , as specified by , , and .

  A string that contains a date and time to convert. An array of allowable formats of . For more information, see the Remarks section. An object that supplies culture-specific format information about . A bitwise combination of enumeration values that indicates the permitted format of . A typical value to specify is . 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 0 and 59 set to the seconds component of the current instance.

  This property is read-only.

  Gets the seconds component of the date represented by this instance.

  0
- Method
  2.0.0.0
  4.0.0.0
  System.DateTime `` ``

  A object consists of a Kind field that indicates whether the time value is based on local time, Coordinated Universal Time (UTC), or neither, and a Ticks field that contains a time value measured in 100-nanosecond ticks. The method creates a new object using the specified parameter and the original time value.

  The returned value does not represent the same instant in time as the parameter, and is not a time zone conversion method. Instead, it leaves the time specified by the parameter unchanged, and sets the property to . For information about time zone conversions, see Converting Times Between Time Zones.

  The method is useful in interoperability scenarios where you receive a object with an unspecified Kind field, but you can determine by independent means that the Ticks field represents local time or UTC.

  Creates a new object that has the same number of ticks as the specified , but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified value.

  A new object that has the same number of ticks as the object represented by the parameter and the value specified by the parameter.

  A date and time. One of the enumeration values that indicates whether the new object represents local time, UTC, or neither.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan ``

  If the date and time of the current instance is earlier than , the method returns a object that represents a negative time span. That is, the value of all of its non-zero properties (such as or ) is negative.

  The method does not consider the value of the property of the two values when performing the subtraction. Before subtracting objects, ensure that the objects represent times in the same time zone. Otherwise, the result will include the difference between time zones.

  The method does consider the difference between time zones when performing the subtraction.

  Subtracts the specified date and time from this instance.

  A time interval that is equal to the date and time represented by this instance minus the date and time represented by .

  The date and time value to subtract. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` The resulting date and time is less than or greater than .

  This method does not change the value of this . Instead, it returns a new whose value is the result of this operation.

  Ordinarily, the method subtracts a object that represents a positive time span and returns a value that is earlier than the date and time of the current instance. However, if the object represents a negative time span, the method returns a value that is later than the date and time of the current instance.

  The method allows you to subtract a time interval that consists of more than one unit of time (such as a given number of hours and a given number of minutes). To subtract a single unit of time (such as years, months, or days) from the instance, you can pass a negative numeric value as a parameter to any of the following methods:

  , to subtract a specific number of years from the current date and time instance.

  , to subtract a specific number of months from the current date and time instance.

  , to subtract a specific number of days from the current date and time instance.

  , to subtract a specific number of hours from the current date and time instance.

  , to subtract a specific number of minutes from the current date and time instance.

  , to subtract a specific number of seconds from the current date and time instance.

  , to subtract a specific number of milliseconds from the current date and time instance.

  , to subtract a specific number of ticks from the current date and time instance.

  Subtracts the specified duration from this instance.

  An object that is equal to the date and time represented by this instance minus the time interval represented by .

  The time interval to subtract. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Byte `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` To be added.

  Returns the current object.

  The current object.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Decimal `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.SByte `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` `` To be added. To be added.

  Converts the current object to an object of a specified type.

  An object of the type specified by the parameter, with a value equivalent to the current object.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt16 `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt32 `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt64 `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  The return value for this member is not used.

  An object that implements the interface. (This parameter is not used; specify null.)
- Method
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  This method populates the parameter with the and property values.

  Populates a object with the data needed to serialize the current object.

  The object to populate with data. The destination for this serialization. (This parameter is not used; specify null.)
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64

  A set to the number of ticks that represent the date and time of the current instance.

  A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

  The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001, which represents . It does not include the number of ticks that are attributable to leap seconds.

  Gets the number of ticks that represent the date and time of this instance.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TimeSpan

  A instance set to the time component of the current instance.

  Unlike the property. which returns a value that represents a date without its time component, the property returns a value that represents a value's time component.

  If you want to display the time of day or retrieve the string representation of the time of day of a value, you can instead call an overload of the method that has a parameter or use the composite formatting feature with the "t" or "T" standard format string.

  Gets the time of day for this instance.

  0
- Method
  2.0.0.0
  4.0.0.0
  System.Int64

  Use the method to convert the value of the current object to a binary value. Subsequently, use the binary value and the method to recreate the original object.

  In some cases, the value returned by the method is not identical to the original value supplied to the method. For more information, see the next section, "Local Time Adjustment".

  ## Local Time Adjustment

  A local time, which is a Coordinated Universal Time adjusted to the local time zone, is represented by a structure whose property has the value . When restoring a local value from the binary representation that is produced by the method, the method may adjust the recreated value so that it is not equal to the original value. This can occur under the following conditions:

  If a local object is serialized in one time zone by the method, and then deserialized in a different time zone by the method, the local time represented by the resulting object is automatically adjusted to the second time zone.

  For example, consider a object that represents a local time of 3 P.M. An application that is executing in the U.S. Pacific Time zone uses the method to convert that object to a binary value. Another application that is executing in the U.S. Eastern Time zone uses the method to convert the binary value to a new object. The value of the new object is 6 P.M., which represents the same point in time as the original 3 P.M. value, but is adjusted to local time in the Eastern Time zone.

  If the binary representation of a local value represents an invalid time in the local time zone of the system on which is called, the time is adjusted so that it is valid.

  For example, the transition from standard time to daylight saving time occurs in the U.S. Pacific Time zone on March 14, 2010, at 2:00 A.M., when the time advances by one hour, to 3:00 A.M. This hour interval is an invalid time, that is, a time interval that does not exist in this time zone. The following example shows that when a time that falls within this range is converted to a binary value by the method and is then restored by the method, the original value is adjusted to become a valid time. You can determine whether a particular date and time value may be subject to modification by passing it to the method, as the example illustrates.

  code reference: System.DateTime.FromBinary#1

  ## Version Considerations

  Starting with the .NET Framework version 2.0, a structure consists of a private Kind field, which indicates whether the specified time value is based on local time, Coordinated Universal Time (UTC), or neither, and a private Ticks field, which contains the number of 100-nanosecond ticks that specify a date and time. The Ticks field can be accessed with the property and the Kind field can be accessed with the property.

  Prior to the .NET Framework 2.0, if you serialized a object manually instead of using a serialization interface such as , you only needed to serialize the Ticks data in the structure. Starting with version 2.0, you must also serialize the Kind data.

  Serializes the current object to a 64-bit binary value that subsequently can be used to recreate the object.

  A 64-bit signed integer that encodes the and properties.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime

  A instance set to the date of the current instance, with the time set to 00:00:00.

  Starting with the .NET Framework version 2.0, the return value is a whose property returns .

  Because it returns the current date without the current time, the property is suitable for use in applications that work with dates only. For details, see Choosing Between DateTime, DateTimeOffset, and TimeZoneInfo. In contrast, the property returns the current time without the current date, and the property returns both the current date and the current time.

  Gets the current date.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64

  A Windows file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC). Windows uses a file time to record when an application creates, accesses, or writes to a file.

  The method uses the property to determine whether the current object is a local time, a UTC time, or an unspecified kind of time which is treated as a local time.

  Converts the value of the current object to a Windows file time.

  The value of the current object expressed as a Windows file time.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64

  A Windows file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC). Windows uses a file time to record when an application creates, accesses, or writes to a file.

  The method uses the property to determine whether the current object is a local time, a UTC time, or an unspecified kind of time which is treated as a UTC time. If it is a local time, it converts the time to UTC before performing the conversion to a Windows file time.

  Converts the value of the current object to a Windows file time.

  The value of the current object expressed as a Windows file time.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime

  The local time is equal to the Coordinated Universal Time (UTC) time plus the UTC offset. For more information about the UTC offset, see . The conversion also takes into account the daylight saving time rule that applies to the time represented by the current object.

  On winxp systems, the method recognizes only the current adjustment rule when converting from UTC to local time. As a result, conversions for periods before the current adjustment rule came into effect may not accurately reflect the difference between UTC and local time.

  Starting with the .NET Framework version 2.0, the value returned by the method is determined by the property of the current object. The following table describes the possible results.

  Kind

  Results

  This instance of is converted to local time.

  No conversion is performed.

  This instance of is assumed to be a UTC time, and the conversion is performed as if were .

  The method converts a value from UTC to local time. To convert the time in any designated time zone to local time, use the method.

  The value returned by the conversion is a whose property always returns . Consequently, a valid result is returned even if is applied repeatedly to the same .

  Converts the value of the current object to local time.

  An object whose property is , and whose value is the local time equivalent to the value of the current object, or if the converted value is too large to be represented by a object, or if the converted value is too small to be represented as a object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The value of the current object is formatted using the pattern defined by the property associated with the current thread culture. The return value is identical to the value returned by specifying the "D" standard DateTime format string with the method.

  The string returned by the method is culture-sensitive. It reflects the pattern defined by the current culture's object. For example, for the en-US culture, the standard long date pattern is "dddd, MMMM dd, yyyy"; for the de-DE culture, it is "dddd, d. MMMM yyyy"; for the ja-JP culture, it is "yyyy'?'M'?'d'?'". The specific format string on a particular computer can also be customized so that it differs from the standard long date format string.

  For more information about the current thread culture, see the property. For more information about format characters, format patterns, and the output they produce, see the Formatting Types topic. For more information about changing the format pattern associated with a format character, see the class.

  Converts the value of the current object to its equivalent long date string representation.

  A string that contains the long date string representation of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The value of the current object is formatted using the pattern defined by the property associated with the current thread culture. The return value is identical to the value returned by specifying the "T" standard date and time format string with the method.

  The string returned by the method is culture-sensitive. It reflects the pattern defined by the property of the current culture's object. For example, for the en-US culture, the standard long time pattern is "h:mm:ss tt"; for the de-DE culture, it is "HH:mm:ss"; for the ja-JP culture, it is "H:mm:ss". The specific format string on a particular computer can also be customized so that it differs from the standard long time format string.

  For more information about the current thread culture, see the property. For more information about format characters, format patterns, and the output they produce, see the Formatting Types topic. For more information about changing the format pattern associated with a format character, see the class.

  Converts the value of the current object to its equivalent long time string representation.

  A string that contains the long time string representation of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double

  An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25.

  The base OLE Automation Date is midnight, 30 December 1899. The minimum OLE Automation date is midnight, 1 January 0100. The maximum OLE Automation Date is the same as , the last moment of 31 December 9999.

  The method throws an if the current instance represents a date that is later than and earlier than midnight on January1, 0100. However, if the value of the current instance is , the method returns 0.

  For more information about OLE Automation, see the MSDN Library.

  Converts the value of this instance to the equivalent OLE Automation date.

  A double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The value of the current object is formatted using the pattern defined by the property associated with the current thread culture. The return value is identical to the value returned by specifying the "d" standard DateTime format string with the method.

  The string returned by the method is culture-sensitive. It reflects the pattern defined by the current culture's object. For example, for the en-US culture, the standard short date pattern is "M/d/yyyy"; for the de-DE culture, it is "dd.MM.yyyy"; for the ja-JP culture, it is "yyyy/M/d". The specific format string on a particular computer can also be customized so that it differs from the standard short date format string.

  For more information about the current thread culture, see the property. For more information about format characters, format patterns, and the output they produce, see the Formatting Types topic. For more information about changing the format pattern associated with a format character, see the class.

  Converts the value of the current object to its equivalent short date string representation.

  A string that contains the short date string representation of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The value of the current object is formatted using the pattern defined by the property associated with the current thread culture. The return value is identical to the value returned by specifying the "t" standard DateTime format string with the method.

  The string returned by the method is culture-sensitive. It reflects the pattern defined by the current culture's object. For example, for the en-US culture, the standard short time pattern is "h:mm tt"; for the de-DE culture, it is "HH:mm"; for the ja-JP culture, it is "H:mm". The specific format string on a particular computer can also be customized so that it differs from the standard short time format string.

  For more information about the current thread culture, see the property. For more information about format characters, format patterns, and the output they produce, see the Formatting Types topic. For more information about changing the format pattern associated with a format character, see the class.

  Converts the value of the current object to its equivalent short time string representation.

  A string that contains the short time string representation of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The value of the current object is formatted using the general date and time format specifier ('G'). To format it using a specific date and time format specifier, call the method. To format it using the general date and time format specifier ('G') for a specific culture, call the method. To format it using a specific date and time format specifier and the conventions of a specific culture, call the method.

  This method uses formatting information derived from the current culture. In particular, it combines the custom format strings returned by the and properties of the object returned by the Thread.CurrentThread.CurrentCulture.DateTimeFormat property. For more information, see . Other overloads of the method enable you to specify the culture whose formatting to use and to define the output pattern of the value.

  Converts the value of the current object to its equivalent string representation.

  A string representation of the value of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  The value of the current object is formatted using the general date and time format specifier ('G'), which formats output using the short date pattern and the long time pattern.

  The format of the short date and long time pattern is defined by the parameter. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the format of date and time data.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the object associated with the current culture is used. For more information, see .

  Converts the value of the current object to its equivalent string representation using the specified culture-specific format information.

  A string representation of value of the current object as specified by .

  An object that supplies culture-specific formatting information. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  The length of the string is 1, and it is not one of the format specifier characters defined for .

  -or-

  The string does not contain a valid custom format pattern.

  The parameter should contain either a single format specifier character (see Standard Date and Time Format Strings) or a custom format pattern (see Custom Date and Time Format Strings) that defines the format of the returned string. If is null or an empty string, the general format specifier, 'G', is used.

  This method uses formatting information derived from the current culture. For more information, see .

  Converts the value of the current object to its equivalent string representation using the specified format.

  A string representation of value of the current object as specified by .

  A standard or custom date and time format string (see Remarks). 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` ``

  The length of the string is 1, and it is not one of the format specifier characters defined for .

  -or-

  The string does not contain a valid custom format pattern.

  The parameter can contain either a single format specifier character (see Standard DateTime Format Strings) or a custom format pattern (see Custom DateTime Format Strings). If is null or an empty string (""), the standard format specifier, "G", is used.

  The parameter defines the pattern that corresponds to the standard format specifiers, as well as the symbols and names of date and time components. The parameter can be any of the following:

  A object that represents the culture whose formatting conventions are to be reflected in the returned string. The object returned by the property defines the formatting of the returned string.

  A object that defines the format of date and time data.

  A custom object that implements the interface. Its method returns a object that provides formatting information.

  If is null, the associated with the current culture is used. For more information, see .

  Converts the value of the current object to its equivalent string representation using the specified format and culture-specific format information.

  A string representation of value of the current object as specified by and .

  A standard or custom date and time format string. An object that supplies culture-specific formatting information. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime

  The Coordinated Universal Time (UTC) is equal to the local time minus the UTC offset. For more information about the UTC offset, see . The conversion also takes into account the daylight saving time rule that applies to the time represented by the current object.

  On winxp systems, the method recognizes only the current adjustment rule when converting from local time to UTC. As a result, conversions for periods before the current adjustment rule came into effect may not accurately reflect the difference between local time and UTC.

  Starting with the .NET Framework version 2.0, the value returned by the method is determined by the property of the current object. The following table describes the possible results.

  Kind

  Results

  No conversion is performed.

  The current object is converted to UTC.

  The current object is assumed to be a local time, and the conversion is performed as if were .

  The method converts a value from local time to UTC. To convert the time in a non-local time zone to UTC, use the method. To convert a time whose offset from UTC is known, use the method.

  If the date and time instance value is an ambiguous time, this method assumes that it is a standard time. (An ambiguous time is one that can map either to a standard time or to a daylight saving time in the local time zone) If the date and time instance value is an invalid time, this method simply subtracts the local time from the local time zone's UTC offset to return UTC. (An invalid time is one that does not exist because of the application of daylight saving time adjustment rules.)

  Converts the value of the current object to Coordinated Universal Time (UTC).

  An object whose property is , and whose value is the UTC equivalent to the value of the current object, or if the converted value is too large to be represented by a object, or if the converted value is too small to be represented by a object.

  0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime

  A instance set to the current date and time in coordinated universal time (UTC).

  The resolution of this property depends on the system timer.

  System

  Approximate Resolution

  Windows NT 3.5 and later

  10 milliseconds

  Windows 98

  55 milliseconds

  Starting with the .NET Framework version 2.0, the return value is a whose property returns .

  An alternative to using is . While the former indicates that a date and time value is Coordinated Universal Time (UTC) by assigning to its property, the latter assigns the date and time value the UTC time's offset (equal to ).

  Gets a object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A between 1 and 9999 set to the year component of the current instance.

  The property returns the year of the current instance in the Gregorian calendar. It does not return the year using the default calendar of the current culture. To retrieve the year using a particular calendar, you can call that calendar's GetYear method, as the following code shows.

  code reference: System.DateTime.Year#1

  Gets the year component of the date represented by this instance.

  0
0