mscorlib(4.0.0.0) API with additions
System.DateTime Struct Reference

Represents an instant in time, typically expressed as a date and time of day. To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.DateTime:
[legend]
Collaboration diagram for System.DateTime:
[legend]

Public Member Functions

 DateTime (long ticks)
 Initializes a new instance of the T:System.DateTime structure to a specified number of ticks. More...
 
 DateTime (long ticks, DateTimeKind kind)
 Initializes a new instance of the T:System.DateTime structure to a specified number of ticks and to Coordinated Universal Time (UTC) or local time. More...
 
internal DateTime (long ticks, DateTimeKind kind, bool isAmbiguousDst)
 
 DateTime (int year, int month, int day)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, and day. More...
 
 DateTime (int year, int month, int day, Calendar calendar)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, and day for the specified calendar. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, and second. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second, DateTimeKind kind)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, second, and Coordinated Universal Time (UTC) or local time. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second, Calendar calendar)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, and second for the specified calendar. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, second, and millisecond. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, DateTimeKind kind)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, second, and millisecond for the specified calendar. More...
 
 DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar, DateTimeKind kind)
 Initializes a new instance of the T:System.DateTime structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time for the specified calendar. More...
 
DateTime Add (TimeSpan value)
 Returns a new T:System.DateTime that adds the value of the specified T:System.TimeSpan to the value of this instance. More...
 
DateTime AddDays (double value)
 Returns a new T:System.DateTime that adds the specified number of days to the value of this instance. More...
 
DateTime AddHours (double value)
 Returns a new T:System.DateTime that adds the specified number of hours to the value of this instance. More...
 
DateTime AddMilliseconds (double value)
 Returns a new T:System.DateTime that adds the specified number of milliseconds to the value of this instance. More...
 
DateTime AddMinutes (double value)
 Returns a new T:System.DateTime that adds the specified number of minutes to the value of this instance. More...
 
DateTime AddMonths (int months)
 Returns a new T:System.DateTime that adds the specified number of months to the value of this instance. More...
 
DateTime AddSeconds (double value)
 Returns a new T:System.DateTime that adds the specified number of seconds to the value of this instance. More...
 
DateTime AddTicks (long value)
 Returns a new T:System.DateTime that adds the specified number of ticks to the value of this instance. More...
 
DateTime AddYears (int value)
 Returns a new T:System.DateTime that adds the specified number of years to the value of this instance. More...
 
int CompareTo (object value)
 Compares the value of this instance to a specified object that contains a specified T:System.DateTime value, and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified T:System.DateTime value. More...
 
int CompareTo (DateTime value)
 Compares the value of this instance to a specified T:System.DateTime value and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified T:System.DateTime value. More...
 
static internal bool LegacyParseMode ()
 
static internal bool EnableAmPmParseAdjustment ()
 
override bool Equals (object value)
 Returns a value indicating whether this instance is equal to a specified object. More...
 
bool Equals (DateTime value)
 Returns a value indicating whether the value of this instance is equal to the value of the specified T:System.DateTime instance. More...
 
void ISerializable. GetObjectData (SerializationInfo info, StreamingContext context)
 Populates a T:System.Runtime.Serialization.SerializationInfo object with the data needed to serialize the current T:System.DateTime object. More...
 
bool IsDaylightSavingTime ()
 Indicates whether this instance of T:System.DateTime is within the daylight saving time range for the current time zone. More...
 
long ToBinary ()
 Serializes the current T:System.DateTime object to a 64-bit binary value that subsequently can be used to recreate the T:System.DateTime object. More...
 
internal long ToBinaryRaw ()
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
internal bool IsAmbiguousDaylightSavingTime ()
 
static internal long GetSystemTimeAsFileTime ()
 
TimeSpan Subtract (DateTime value)
 Subtracts the specified date and time from this instance. More...
 
DateTime Subtract (TimeSpan value)
 Subtracts the specified duration from this instance. More...
 
double ToOADate ()
 Converts the value of this instance to the equivalent OLE Automation date. More...
 
long ToFileTime ()
 Converts the value of the current T:System.DateTime object to a Windows file time. More...
 
long ToFileTimeUtc ()
 Converts the value of the current T:System.DateTime object to a Windows file time. More...
 
DateTime ToLocalTime ()
 Converts the value of the current T:System.DateTime object to local time. More...
 
internal DateTime ToLocalTime (bool throwOnOverflow)
 
string ToLongDateString ()
 Converts the value of the current T:System.DateTime object to its equivalent long date string representation. More...
 
string ToLongTimeString ()
 Converts the value of the current T:System.DateTime object to its equivalent long time string representation. More...
 
string ToShortDateString ()
 Converts the value of the current T:System.DateTime object to its equivalent short date string representation. More...
 
string ToShortTimeString ()
 Converts the value of the current T:System.DateTime object to its equivalent short time string representation. More...
 
override string ToString ()
 Converts the value of the current T:System.DateTime object to its equivalent string representation using the formatting conventions of the current culture. More...
 
string ToString (string format)
 Converts the value of the current T:System.DateTime object to its equivalent string representation using the specified format and the formatting conventions of the current culture. More...
 
string ToString (IFormatProvider provider)
 Converts the value of the current T:System.DateTime object to its equivalent string representation using the specified culture-specific format information. More...
 
string ToString (string format, IFormatProvider provider)
 Converts the value of the current T:System.DateTime object to its equivalent string representation using the specified format and culture-specific format information. More...
 
DateTime ToUniversalTime ()
 Converts the value of the current T:System.DateTime object to Coordinated Universal Time (UTC). More...
 
string [] GetDateTimeFormats ()
 Converts the value of this instance to all the string representations supported by the standard date and time format specifiers. More...
 
string [] GetDateTimeFormats (IFormatProvider provider)
 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. More...
 
string [] GetDateTimeFormats (char format)
 Converts the value of this instance to all the string representations supported by the specified standard date and time format specifier. More...
 
string [] GetDateTimeFormats (char format, IFormatProvider provider)
 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. More...
 
TypeCode GetTypeCode ()
 Returns the T:System.TypeCode for value type T:System.DateTime. More...
 
bool IConvertible. ToBoolean (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
char IConvertible. ToChar (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
sbyte IConvertible. ToSByte (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
byte IConvertible. ToByte (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
short IConvertible. ToInt16 (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
ushort IConvertible. ToUInt16 (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
int IConvertible. ToInt32 (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
uint IConvertible. ToUInt32 (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
long IConvertible. ToInt64 (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
ulong IConvertible. ToUInt64 (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
float IConvertible. ToSingle (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
double IConvertible. ToDouble (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
decimal IConvertible. ToDecimal (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
DateTime IConvertible. ToDateTime (IFormatProvider provider)
 Returns the current T:System.DateTime object. More...
 
object IConvertible. ToType (Type type, IFormatProvider provider)
 Converts the current T:System.DateTime object to an object of a specified type. More...
 
- Public Member Functions inherited from System.IEquatable< DateTime >
bool Equals (T other)
 Indicates whether the current object is equal to another object of the same type. More...
 

Static Public Member Functions

static int Compare (DateTime t1, DateTime t2)
 Compares two instances of T:System.DateTime and returns an integer that indicates whether the first instance is earlier than, the same as, or later than the second instance. More...
 
static int DaysInMonth (int year, int month)
 Returns the number of days in the specified month and year. More...
 
static internal long DoubleDateToTicks (double value)
 
static bool Equals (DateTime t1, DateTime t2)
 Returns a value indicating whether two T:System.DateTime instances have the same date and time value. More...
 
static DateTime FromBinary (long dateData)
 Deserializes a 64-bit binary value and recreates an original serialized T:System.DateTime object. More...
 
static internal DateTime FromBinaryRaw (long dateData)
 
static DateTime FromFileTime (long fileTime)
 Converts the specified Windows file time to an equivalent local time. More...
 
static DateTime FromFileTimeUtc (long fileTime)
 Converts the specified Windows file time to an equivalent UTC time. More...
 
static DateTime FromOADate (double d)
 Returns a T:System.DateTime equivalent to the specified OLE Automation Date. More...
 
static DateTime SpecifyKind (DateTime value, DateTimeKind kind)
 Creates a new T:System.DateTime object that has the same number of ticks as the specified T:System.DateTime, but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified T:System.DateTimeKind value. More...
 
static bool IsLeapYear (int year)
 Returns an indication whether the specified year is a leap year. More...
 
static DateTime Parse (string s)
 Converts the string representation of a date and time to its T:System.DateTime equivalent. More...
 
static DateTime Parse (string s, IFormatProvider provider)
 Converts the string representation of a date and time to its T:System.DateTime equivalent by using culture-specific format information. More...
 
static DateTime Parse (string s, IFormatProvider provider, DateTimeStyles styles)
 Converts the string representation of a date and time to its T:System.DateTime equivalent by using culture-specific format information and formatting style. More...
 
static DateTime ParseExact (string s, string format, IFormatProvider provider)
 Converts the specified string representation of a date and time to its T:System.DateTime equivalent using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly. More...
 
static DateTime ParseExact (string s, string format, IFormatProvider provider, DateTimeStyles style)
 Converts the specified string representation of a date and time to its T:System.DateTime 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. More...
 
static DateTime ParseExact (string s, string[] formats, IFormatProvider provider, DateTimeStyles style)
 Converts the specified string representation of a date and time to its T:System.DateTime 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. More...
 
static bool TryParse (string s, out DateTime result)
 Converts the specified string representation of a date and time to its T:System.DateTime equivalent and returns a value that indicates whether the conversion succeeded. More...
 
static bool TryParse (string s, IFormatProvider provider, DateTimeStyles styles, out DateTime result)
 Converts the specified string representation of a date and time to its T:System.DateTime equivalent using the specified culture-specific format information and formatting style, and returns a value that indicates whether the conversion succeeded. More...
 
static bool TryParseExact (string s, string format, IFormatProvider provider, DateTimeStyles style, out DateTime result)
 Converts the specified string representation of a date and time to its T:System.DateTime equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded. More...
 
static bool TryParseExact (string s, string[] formats, IFormatProvider provider, DateTimeStyles style, out DateTime result)
 Converts the specified string representation of a date and time to its T:System.DateTime 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. The method returns a value that indicates whether the conversion succeeded. More...
 
static DateTime operator+ (DateTime d, TimeSpan t)
 Adds a specified time interval to a specified date and time, yielding a new date and time. More...
 
static DateTime operator - (DateTime d, TimeSpan t)
 Subtracts a specified time interval from a specified date and time and returns a new date and time. More...
 
static TimeSpan operator - (DateTime d1, DateTime d2)
 Subtracts a specified date and time from another specified date and time and returns a time interval. More...
 
static bool operator== (DateTime d1, DateTime d2)
 Determines whether two specified instances of T:System.DateTime are equal. More...
 
static bool operator != (DateTime d1, DateTime d2)
 Determines whether two specified instances of T:System.DateTime are not equal. More...
 
static bool operator< (DateTime t1, DateTime t2)
 Determines whether one specified T:System.DateTime is earlier than another specified T:System.DateTime. More...
 
static bool operator<= (DateTime t1, DateTime t2)
 Determines whether one specified T:System.DateTime represents a date and time that is the same as or earlier than another specified T:System.DateTime. More...
 
static bool operator > (DateTime t1, DateTime t2)
 Determines whether one specified T:System.DateTime is later than another specified T:System.DateTime. More...
 
static bool operator >= (DateTime t1, DateTime t2)
 Determines whether one specified T:System.DateTime represents a date and time that is the same as or later than another specified T:System.DateTime. More...
 
static internal bool TryCreate (int year, int month, int day, int hour, int minute, int second, int millisecond, out DateTime result)
 

Public Attributes

internal const int DaysTo1970 = 719162
 
internal const long MinTicks = 0L
 
internal const long MaxTicks = 3155378975999999999L
 
internal long InternalTicks => (long)(dateData & 0x3FFFFFFFFFFFFFFF)
 

Static Public Attributes

static readonly DateTime MinValue = new DateTime(0L, DateTimeKind.Unspecified)
 Represents the smallest possible value of T:System.DateTime. This field is read-only. More...
 
static readonly DateTime MaxValue = new DateTime(3155378975999999999L, DateTimeKind.Unspecified)
 Represents the largest possible value of T:System.DateTime. This field is read-only. More...
 

Properties

DateTime Date [get]
 Gets the date component of this instance. More...
 
int Day [get]
 Gets the day of the month represented by this instance. More...
 
DayOfWeek DayOfWeek [get]
 Gets the day of the week represented by this instance. More...
 
int DayOfYear [get]
 Gets the day of the year represented by this instance. More...
 
int Hour [get]
 Gets the hour component of the date represented by this instance. More...
 
DateTimeKind Kind [get]
 Gets a value that indicates whether the time represented by this instance is based on local time, Coordinated Universal Time (UTC), or neither. More...
 
int Millisecond [get]
 Gets the milliseconds component of the date represented by this instance. More...
 
int Minute [get]
 Gets the minute component of the date represented by this instance. More...
 
int Month [get]
 Gets the month component of the date represented by this instance. More...
 
static DateTime Now [get]
 Gets a T:System.DateTime object that is set to the current date and time on this computer, expressed as the local time. More...
 
static DateTime UtcNow [get]
 Gets a T:System.DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC). More...
 
int Second [get]
 Gets the seconds component of the date represented by this instance. More...
 
long Ticks [get]
 Gets the number of ticks that represent the date and time of this instance. More...
 
TimeSpan TimeOfDay [get]
 Gets the time of day for this instance. More...
 
static DateTime Today [get]
 Gets the current date. More...
 
int Year [get]
 Gets the year component of the date represented by this instance. More...
 

Detailed Description

Represents an instant in time, typically expressed as a date and time of day. To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 13 of file DateTime.cs.

Constructor & Destructor Documentation

◆ DateTime() [1/11]

System.DateTime.DateTime ( long  ticks)

Initializes a new instance of the T:System.DateTime structure to a specified number of ticks.

Parameters
ticksA 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.
Exceptions
T:System.ArgumentOutOfRangeExceptionticks is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 364 of file DateTime.cs.

◆ DateTime() [2/11]

System.DateTime.DateTime ( long  ticks,
DateTimeKind  kind 
)

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

Parameters
ticksA 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.
kindOne of the enumeration values that indicates whether ticks specifies a local time, Coordinated Universal Time (UTC), or neither.
Exceptions
T:System.ArgumentOutOfRangeExceptionticks is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.
T:System.ArgumentExceptionkind is not one of the T:System.DateTimeKind values.

Definition at line 386 of file DateTime.cs.

◆ DateTime() [3/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day 
)

Initializes a new instance of the T:System.DateTime structure to the specified year, month, and day.

Parameters
yearThe year (1 through 9999).
monthThe month (1 through 12).
dayThe day (1 through the number of days in month ).
Exceptions
T:System.ArgumentOutOfRangeExceptionyear is less than 1 or greater than 9999.-or- month is less than 1 or greater than 12.-or- day is less than 1 or greater than the number of days in month .

Definition at line 417 of file DateTime.cs.

◆ DateTime() [4/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
Calendar  calendar 
)

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

Parameters
yearThe year (1 through the number of years in calendar ).
monthThe month (1 through the number of months in calendar ).
dayThe day (1 through the number of days in month ).
calendarThe calendar that is used to interpret year , month , and day .
Exceptions
T:System.ArgumentNullExceptioncalendar is null.
T:System.ArgumentOutOfRangeExceptionyear is not in the range supported by calendar .-or- month is less than 1 or greater than the number of months in calendar .-or- day is less than 1 or greater than the number of days in month .

Definition at line 433 of file DateTime.cs.

◆ DateTime() [5/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second 
)

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

Parameters
yearThe year (1 through 9999).
monthThe month (1 through 12).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
Exceptions
T:System.ArgumentOutOfRangeExceptionyear is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23. -or- minute is less than 0 or greater than 59. -or- second is less than 0 or greater than 59.

Definition at line 453 of file DateTime.cs.

◆ DateTime() [6/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
DateTimeKind  kind 
)

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

Parameters
yearThe year (1 through 9999).
monthThe month (1 through 12).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
kindOne of the enumeration values that indicates whether year , month , day , hour , minute and second specify a local time, Coordinated Universal Time (UTC), or neither.
Exceptions
T:System.ArgumentOutOfRangeExceptionyear is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23. -or- minute is less than 0 or greater than 59. -or- second is less than 0 or greater than 59.
T:System.ArgumentExceptionkind is not one of the T:System.DateTimeKind values.

Definition at line 476 of file DateTime.cs.

◆ DateTime() [7/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
Calendar  calendar 
)

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

Parameters
yearThe year (1 through the number of years in calendar ).
monthThe month (1 through the number of months in calendar ).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
calendarThe calendar that is used to interpret year , month , and day .
Exceptions
T:System.ArgumentNullExceptioncalendar is null.
T:System.ArgumentOutOfRangeExceptionyear is not in the range supported by calendar .-or- month is less than 1 or greater than the number of months in calendar .-or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23 -or- minute is less than 0 or greater than 59. -or- second is less than 0 or greater than 59.

Definition at line 503 of file DateTime.cs.

◆ DateTime() [8/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond 
)

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

Parameters
yearThe year (1 through 9999).
monthThe month (1 through 12).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
millisecondThe milliseconds (0 through 999).
Exceptions
T:System.ArgumentOutOfRangeExceptionyear is less than 1 or greater than 9999.-or- month is less than 1 or greater than 12.-or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23.-or- minute is less than 0 or greater than 59.-or- second is less than 0 or greater than 59.-or- millisecond is less than 0 or greater than 999.

Definition at line 529 of file DateTime.cs.

◆ DateTime() [9/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond,
DateTimeKind  kind 
)

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

Parameters
yearThe year (1 through 9999).
monthThe month (1 through 12).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
millisecondThe milliseconds (0 through 999).
kindOne of the enumeration values that indicates whether year , month , day , hour , minute , second , and millisecond specify a local time, Coordinated Universal Time (UTC), or neither.
Exceptions
T:System.ArgumentOutOfRangeExceptionyear is less than 1 or greater than 9999.-or- month is less than 1 or greater than 12.-or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23.-or- minute is less than 0 or greater than 59.-or- second is less than 0 or greater than 59.-or- millisecond is less than 0 or greater than 999.
T:System.ArgumentExceptionkind is not one of the T:System.DateTimeKind values.

Definition at line 564 of file DateTime.cs.

◆ DateTime() [10/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond,
Calendar  calendar 
)

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

Parameters
yearThe year (1 through the number of years in calendar ).
monthThe month (1 through the number of months in calendar ).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
millisecondThe milliseconds (0 through 999).
calendarThe calendar that is used to interpret year , month , and day .
Exceptions
T:System.ArgumentNullExceptioncalendar is null.
T:System.ArgumentOutOfRangeExceptionyear is not in the range supported by calendar .-or- month is less than 1 or greater than the number of months in calendar .-or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23.-or- minute is less than 0 or greater than 59.-or- second is less than 0 or greater than 59.-or- millisecond is less than 0 or greater than 999.

Definition at line 602 of file DateTime.cs.

◆ DateTime() [11/11]

System.DateTime.DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond,
Calendar  calendar,
DateTimeKind  kind 
)

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

Parameters
yearThe year (1 through the number of years in calendar ).
monthThe month (1 through the number of months in calendar ).
dayThe day (1 through the number of days in month ).
hourThe hours (0 through 23).
minuteThe minutes (0 through 59).
secondThe seconds (0 through 59).
millisecondThe milliseconds (0 through 999).
calendarThe calendar that is used to interpret year , month , and day .
kindOne of the enumeration values that indicates whether year , month , day , hour , minute , second , and millisecond specify a local time, Coordinated Universal Time (UTC), or neither.
Exceptions
T:System.ArgumentNullExceptioncalendar is null.
T:System.ArgumentOutOfRangeExceptionyear is not in the range supported by calendar .-or- month is less than 1 or greater than the number of months in calendar .-or- day is less than 1 or greater than the number of days in month .-or- hour is less than 0 or greater than 23.-or- minute is less than 0 or greater than 59.-or- second is less than 0 or greater than 59.-or- millisecond is less than 0 or greater than 999.
T:System.ArgumentExceptionkind is not one of the T:System.DateTimeKind values.

Definition at line 643 of file DateTime.cs.

Member Function Documentation

◆ Add()

DateTime System.DateTime.Add ( TimeSpan  value)

Returns a new T:System.DateTime that adds the value of the specified T:System.TimeSpan to the value of this instance.

Parameters
valueA positive or negative time interval.
Returns
An object whose value is the sum of the date and time represented by this instance and the time interval represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 718 of file DateTime.cs.

◆ AddDays()

DateTime System.DateTime.AddDays ( double  value)

Returns a new T:System.DateTime that adds the specified number of days to the value of this instance.

Parameters
valueA number of whole and fractional days. The value parameter can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by this instance and the number of days represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 738 of file DateTime.cs.

◆ AddHours()

DateTime System.DateTime.AddHours ( double  value)

Returns a new T:System.DateTime that adds the specified number of hours to the value of this instance.

Parameters
valueA number of whole and fractional hours. The value parameter can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by this instance and the number of hours represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 748 of file DateTime.cs.

◆ AddMilliseconds()

DateTime System.DateTime.AddMilliseconds ( double  value)

Returns a new T:System.DateTime that adds the specified number of milliseconds to the value of this instance.

Parameters
valueA number of whole and fractional milliseconds. The value parameter can be negative or positive. Note that this value is rounded to the nearest integer.
Returns
An object whose value is the sum of the date and time represented by this instance and the number of milliseconds represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 758 of file DateTime.cs.

◆ AddMinutes()

DateTime System.DateTime.AddMinutes ( double  value)

Returns a new T:System.DateTime that adds the specified number of minutes to the value of this instance.

Parameters
valueA number of whole and fractional minutes. The value parameter can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by this instance and the number of minutes represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 768 of file DateTime.cs.

◆ AddMonths()

DateTime System.DateTime.AddMonths ( int  months)

Returns a new T:System.DateTime that adds the specified number of months to the value of this instance.

Parameters
monthsA number of months. The months parameter can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by this instance and months .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.-or- months is less than -120,000 or greater than 120,000.

Definition at line 779 of file DateTime.cs.

◆ AddSeconds()

DateTime System.DateTime.AddSeconds ( double  value)

Returns a new T:System.DateTime that adds the specified number of seconds to the value of this instance.

Parameters
valueA number of whole and fractional seconds. The value parameter can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by this instance and the number of seconds represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 816 of file DateTime.cs.

◆ AddTicks()

DateTime System.DateTime.AddTicks ( long  value)

Returns a new T:System.DateTime that adds the specified number of ticks to the value of this instance.

Parameters
valueA number of 100-nanosecond ticks. The value parameter can be positive or negative.
Returns
An object whose value is the sum of the date and time represented by this instance and the time represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 826 of file DateTime.cs.

◆ AddYears()

DateTime System.DateTime.AddYears ( int  value)

Returns a new T:System.DateTime that adds the specified number of years to the value of this instance.

Parameters
valueA number of years. The value parameter can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by this instance and the number of years represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionvalue or the resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 842 of file DateTime.cs.

◆ Compare()

static int System.DateTime.Compare ( DateTime  t1,
DateTime  t2 
)
static

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

Parameters
t1The first object to compare.
t2The second object to compare.
Returns
A signed number indicating the relative values of t1 and t2 .Value Type Condition Less than zero t1 is earlier than t2 . Zero t1 is the same as t2 . Greater than zero t1 is later than t2 .

Definition at line 859 of file DateTime.cs.

◆ CompareTo() [1/2]

int System.DateTime.CompareTo ( object  value)

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

Parameters
valueA boxed object to compare, or null.
Returns
A signed number indicating the relative values of this instance and value .Value Description Less than zero This instance is earlier than value . Zero This instance is the same as value . Greater than zero This instance is later than value , or value is null.
Exceptions
T:System.ArgumentExceptionvalue is not a T:System.DateTime.

Definition at line 879 of file DateTime.cs.

◆ CompareTo() [2/2]

int System.DateTime.CompareTo ( DateTime  value)

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

Parameters
valueThe object to compare to the current instance.
Returns
A signed number indicating the relative values of this instance and the value parameter.Value Description Less than zero This instance is earlier than value . Zero This instance is the same as value . Greater than zero This instance is later than value .

Definition at line 906 of file DateTime.cs.

◆ DaysInMonth()

static int System.DateTime.DaysInMonth ( int  year,
int  month 
)
static

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

Parameters
yearThe year.
monthThe month (a number ranging from 1 to 12).
Returns
The number of days in month for the specified year .For example, if month equals 2 for February, the return value is 28 or 29 depending upon whether year is a leap year.
Exceptions
T:System.ArgumentOutOfRangeExceptionmonth is less than 1 or greater than 12.-or- year is less than 1 or greater than 9999.

Definition at line 953 of file DateTime.cs.

◆ Equals() [1/3]

override bool System.DateTime.Equals ( object  value)

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

Parameters
valueThe object to compare to this instance.
Returns
true if value is an instance of T:System.DateTime and equals the value of this instance; otherwise, false.

Definition at line 999 of file DateTime.cs.

◆ Equals() [2/3]

bool System.DateTime.Equals ( DateTime  value)

Returns a value indicating whether the value of this instance is equal to the value of the specified T:System.DateTime instance.

Parameters
valueThe object to compare to this instance.
Returns
true if the value parameter equals the value of this instance; otherwise, false.

Definition at line 1014 of file DateTime.cs.

◆ Equals() [3/3]

static bool System.DateTime.Equals ( DateTime  t1,
DateTime  t2 
)
static

Returns a value indicating whether two T:System.DateTime instances have the same date and time value.

Parameters
t1The first object to compare.
t2The second object to compare.
Returns
true if the two values are equal; otherwise, false.

Definition at line 1026 of file DateTime.cs.

◆ FromBinary()

static DateTime System.DateTime.FromBinary ( long  dateData)
static

Deserializes a 64-bit binary value and recreates an original serialized T:System.DateTime object.

Parameters
dateDataA 64-bit signed integer that encodes the P:System.DateTime.Kind property in a 2-bit field and the P:System.DateTime.Ticks property in a 62-bit field.
Returns
An object that is equivalent to the T:System.DateTime object that was serialized by the M:System.DateTime.ToBinary method.
Exceptions
T:System.ArgumentExceptiondateData is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 1037 of file DateTime.cs.

◆ FromFileTime()

static DateTime System.DateTime.FromFileTime ( long  fileTime)
static

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

Parameters
fileTimeA Windows file time expressed in ticks.
Returns
An object that represents the local time equivalent of the date and time represented by the fileTime parameter.
Exceptions
T:System.ArgumentOutOfRangeExceptionfileTime is less than 0 or represents a time greater than F:System.DateTime.MaxValue.

Definition at line 1092 of file DateTime.cs.

◆ FromFileTimeUtc()

static DateTime System.DateTime.FromFileTimeUtc ( long  fileTime)
static

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

Parameters
fileTimeA Windows file time expressed in ticks.
Returns
An object that represents the UTC time equivalent of the date and time represented by the fileTime parameter.
Exceptions
T:System.ArgumentOutOfRangeExceptionfileTime is less than 0 or represents a time greater than F:System.DateTime.MaxValue.

Definition at line 1103 of file DateTime.cs.

◆ FromOADate()

static DateTime System.DateTime.FromOADate ( double  d)
static

Returns a T:System.DateTime equivalent to the specified OLE Automation Date.

Parameters
dAn OLE Automation Date value.
Returns
An object that represents the same date and time as d .
Exceptions
T:System.ArgumentExceptionThe date is not a valid OLE Automation Date value.

Definition at line 1118 of file DateTime.cs.

◆ GetDateTimeFormats() [1/4]

string [] System.DateTime.GetDateTimeFormats ( )

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

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

Definition at line 1753 of file DateTime.cs.

◆ GetDateTimeFormats() [2/4]

string [] System.DateTime.GetDateTimeFormats ( IFormatProvider  provider)

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.

Parameters
providerAn object that supplies culture-specific formatting information about this instance.
Returns
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.

Definition at line 1762 of file DateTime.cs.

◆ GetDateTimeFormats() [3/4]

string [] System.DateTime.GetDateTimeFormats ( char  format)

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

Parameters
formatA standard date and time format string (see Remarks).
Returns
A string array where each element is the representation of the value of this instance formatted with the format standard date and time format specifier.
Exceptions
T:System.FormatExceptionformat is not a valid standard date and time format specifier character.

Definition at line 1773 of file DateTime.cs.

◆ GetDateTimeFormats() [4/4]

string [] System.DateTime.GetDateTimeFormats ( char  format,
IFormatProvider  provider 
)

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.

Parameters
formatA date and time format string (see Remarks).
providerAn object that supplies culture-specific formatting information about this instance.
Returns
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.
Exceptions
T:System.FormatExceptionformat is not a valid standard date and time format specifier character.

Definition at line 1785 of file DateTime.cs.

◆ GetHashCode()

override int System.DateTime.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

Definition at line 1229 of file DateTime.cs.

◆ GetObjectData()

void ISerializable. System.DateTime.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)

Populates a T:System.Runtime.Serialization.SerializationInfo object with the data needed to serialize the current T:System.DateTime object.

Parameters
infoThe object to populate with data.
contextThe destination for this serialization. (This parameter is not used; specify null.)
Exceptions
T:System.ArgumentNullExceptioninfo is null.

Implements System.Runtime.Serialization.ISerializable.

Definition at line 1129 of file DateTime.cs.

◆ GetTypeCode()

TypeCode System.DateTime.GetTypeCode ( )

Returns the T:System.TypeCode for value type T:System.DateTime.

Returns
The enumerated constant, F:System.TypeCode.DateTime.

Implements System.IConvertible.

Definition at line 1792 of file DateTime.cs.

◆ IsDaylightSavingTime()

bool System.DateTime.IsDaylightSavingTime ( )

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

Returns
true if the value of the P:System.DateTime.Kind property is F:System.DateTimeKind.Local or F:System.DateTimeKind.Unspecified and the value of this instance of T:System.DateTime is within the daylight saving time range for the local time zone; false if P:System.DateTime.Kind is F:System.DateTimeKind.Utc.

Definition at line 1143 of file DateTime.cs.

◆ IsLeapYear()

static bool System.DateTime.IsLeapYear ( int  year)
static

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

Parameters
yearA 4-digit year.
Returns
true if year is a leap year; otherwise, false.
Exceptions
T:System.ArgumentOutOfRangeExceptionyear is less than 1 or greater than 9999.

Definition at line 1251 of file DateTime.cs.

◆ operator !=()

static bool System.DateTime.operator != ( DateTime  d1,
DateTime  d2 
)
static

Determines whether two specified instances of T:System.DateTime are not equal.

Parameters
d1The first object to compare.
d2The second object to compare.
Returns
true if d1 and d2 do not represent the same date and time; otherwise, false.

Definition at line 1701 of file DateTime.cs.

◆ operator -() [1/2]

static DateTime System.DateTime.operator - ( DateTime  d,
TimeSpan  t 
)
static

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

Parameters
dThe date and time value to subtract from.
tThe time interval to subtract.
Returns
An object whose value is the value of d minus the value of t .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 1663 of file DateTime.cs.

◆ operator -() [2/2]

static TimeSpan System.DateTime.operator - ( DateTime  d1,
DateTime  d2 
)
static

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

Parameters
d1The date and time value to subtract from (the minuend).
d2The date and time value to subtract (the subtrahend).
Returns
The time interval between d1 and d2 ; that is, d1 minus d2 .

Definition at line 1679 of file DateTime.cs.

◆ operator >()

static bool System.DateTime.operator > ( DateTime  t1,
DateTime  t2 
)
static

Determines whether one specified T:System.DateTime is later than another specified T:System.DateTime.

Parameters
t1The first object to compare.
t2The second object to compare.
Returns
true if t1 is later than t2 ; otherwise, false.

Definition at line 1734 of file DateTime.cs.

◆ operator >=()

static bool System.DateTime.operator >= ( DateTime  t1,
DateTime  t2 
)
static

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

Parameters
t1The first object to compare.
t2The second object to compare.
Returns
true if t1 is the same as or later than t2 ; otherwise, false.

Definition at line 1745 of file DateTime.cs.

◆ operator+()

static DateTime System.DateTime.operator+ ( DateTime  d,
TimeSpan  t 
)
static

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

Parameters
dThe date and time value to add.
tThe time interval to add.
Returns
An object that is the sum of the values of d and t .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTime is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 1646 of file DateTime.cs.

◆ operator<()

static bool System.DateTime.operator< ( DateTime  t1,
DateTime  t2 
)
static

Determines whether one specified T:System.DateTime is earlier than another specified T:System.DateTime.

Parameters
t1The first object to compare.
t2The second object to compare.
Returns
true if t1 is earlier than t2 ; otherwise, false.

Definition at line 1712 of file DateTime.cs.

◆ operator<=()

static bool System.DateTime.operator<= ( DateTime  t1,
DateTime  t2 
)
static

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

Parameters
t1The first object to compare.
t2The second object to compare.
Returns
true if t1 is the same as or earlier than t2 ; otherwise, false.

Definition at line 1723 of file DateTime.cs.

◆ operator==()

static bool System.DateTime.operator== ( DateTime  d1,
DateTime  d2 
)
static

Determines whether two specified instances of T:System.DateTime are equal.

Parameters
d1The first object to compare.
d2The second object to compare.
Returns
true if d1 and d2 represent the same date and time; otherwise, false.

Definition at line 1690 of file DateTime.cs.

◆ Parse() [1/3]

static DateTime System.DateTime.Parse ( string  s)
static

Converts the string representation of a date and time to its T:System.DateTime equivalent.

Parameters
sA string that contains a date and time to convert.
Returns
An object that is equivalent to the date and time contained in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions does not contain a valid string representation of a date and time.

Definition at line 1276 of file DateTime.cs.

◆ Parse() [2/3]

static DateTime System.DateTime.Parse ( string  s,
IFormatProvider  provider 
)
static

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

Parameters
sA string that contains a date and time to convert.
providerAn object that supplies culture-specific format information about s .
Returns
An object that is equivalent to the date and time contained in s as specified by provider .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions does not contain a valid string representation of a date and time.

Definition at line 1290 of file DateTime.cs.

◆ Parse() [3/3]

static DateTime System.DateTime.Parse ( string  s,
IFormatProvider  provider,
DateTimeStyles  styles 
)
static

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

Parameters
sA string that contains a date and time to convert.
providerAn object that supplies culture-specific formatting information about s .
stylesA bitwise combination of the enumeration values that indicates the style elements that can be present in s 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 F:System.Globalization.DateTimeStyles.None.
Returns
An object that is equivalent to the date and time contained in s , as specified by provider and styles .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions does not contain a valid string representation of a date and time.
T:System.ArgumentExceptionstyles contains an invalid combination of T:System.Globalization.DateTimeStyles values. For example, both F:System.Globalization.DateTimeStyles.AssumeLocal and F:System.Globalization.DateTimeStyles.AssumeUniversal.

Definition at line 1307 of file DateTime.cs.

◆ ParseExact() [1/3]

static DateTime System.DateTime.ParseExact ( string  s,
string  format,
IFormatProvider  provider 
)
static

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

Parameters
sA string that contains a date and time to convert.
formatA format specifier that defines the required format of s . For more information, see the Remarks section.
providerAn object that supplies culture-specific format information about s .
Returns
An object that is equivalent to the date and time contained in s , as specified by format and provider .
Exceptions
T:System.ArgumentNullExceptions or format is null.
T:System.FormatExceptions or format is an empty string. -or- s does not contain a date and time that corresponds to the pattern specified in format . -or- The hour component and the AM/PM designator in s do not agree.

Definition at line 1325 of file DateTime.cs.

◆ ParseExact() [2/3]

static DateTime System.DateTime.ParseExact ( string  s,
string  format,
IFormatProvider  provider,
DateTimeStyles  style 
)
static

Converts the specified string representation of a date and time to its T:System.DateTime 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.

Parameters
sA string containing a date and time to convert.
formatA format specifier that defines the required format of s . For more information, see the Remarks section.
providerAn object that supplies culture-specific formatting information about s .
styleA bitwise combination of the enumeration values that provides additional information about s , about style elements that may be present in s , or about the conversion from s to a T:System.DateTime value. A typical value to specify is F:System.Globalization.DateTimeStyles.None.
Returns
An object that is equivalent to the date and time contained in s , as specified by format , provider , and style .
Exceptions
T:System.ArgumentNullExceptions or format is null.
T:System.FormatExceptions or format is an empty string. -or- s does not contain a date and time that corresponds to the pattern specified in format . -or- The hour component and the AM/PM designator in s do not agree.
T:System.ArgumentExceptionstyle contains an invalid combination of T:System.Globalization.DateTimeStyles values. For example, both F:System.Globalization.DateTimeStyles.AssumeLocal and F:System.Globalization.DateTimeStyles.AssumeUniversal.

Definition at line 1345 of file DateTime.cs.

◆ ParseExact() [3/3]

static DateTime System.DateTime.ParseExact ( string  s,
string []  formats,
IFormatProvider  provider,
DateTimeStyles  style 
)
static

Converts the specified string representation of a date and time to its T:System.DateTime 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.

Parameters
sA string that contains a date and time to convert.
formatsAn array of allowable formats of s . For more information, see the Remarks section.
providerAn object that supplies culture-specific format information about s .
styleA bitwise combination of enumeration values that indicates the permitted format of s . A typical value to specify is F:System.Globalization.DateTimeStyles.None.
Returns
An object that is equivalent to the date and time contained in s , as specified by formats , provider , and style .
Exceptions
T:System.ArgumentNullExceptions or formats is null.
T:System.FormatExceptions is an empty string. -or- an element of formats is an empty string. -or- s does not contain a date and time that corresponds to any element of formats . -or- The hour component and the AM/PM designator in s do not agree.
T:System.ArgumentExceptionstyle contains an invalid combination of T:System.Globalization.DateTimeStyles values. For example, both F:System.Globalization.DateTimeStyles.AssumeLocal and F:System.Globalization.DateTimeStyles.AssumeUniversal.

Definition at line 1366 of file DateTime.cs.

◆ SpecifyKind()

static DateTime System.DateTime.SpecifyKind ( DateTime  value,
DateTimeKind  kind 
)
static

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

Parameters
valueA date and time.
kindOne of the enumeration values that indicates whether the new object represents local time, UTC, or neither.
Returns
A new object that has the same number of ticks as the object represented by the value parameter and the T:System.DateTimeKind value specified by the kind parameter.

Definition at line 1157 of file DateTime.cs.

◆ Subtract() [1/2]

TimeSpan System.DateTime.Subtract ( DateTime  value)

Subtracts the specified date and time from this instance.

Parameters
valueThe date and time value to subtract.
Returns
A time interval that is equal to the date and time represented by this instance minus the date and time represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe result is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 1377 of file DateTime.cs.

◆ Subtract() [2/2]

DateTime System.DateTime.Subtract ( TimeSpan  value)

Subtracts the specified duration from this instance.

Parameters
valueThe time interval to subtract.
Returns
An object that is equal to the date and time represented by this instance minus the time interval represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe result is less than F:System.DateTime.MinValue or greater than F:System.DateTime.MaxValue.

Definition at line 1387 of file DateTime.cs.

◆ ToBinary()

long System.DateTime.ToBinary ( )

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

Returns
A 64-bit signed integer that encodes the P:System.DateTime.Kind and P:System.DateTime.Ticks properties.

Definition at line 1165 of file DateTime.cs.

◆ ToBoolean()

bool IConvertible. System.DateTime.ToBoolean ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1802 of file DateTime.cs.

◆ ToByte()

byte IConvertible. System.DateTime.ToByte ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1832 of file DateTime.cs.

◆ ToChar()

char IConvertible. System.DateTime.ToChar ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1812 of file DateTime.cs.

◆ ToDateTime()

DateTime IConvertible. System.DateTime.ToDateTime ( IFormatProvider  provider)

Returns the current T:System.DateTime object.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The current object.

Implements System.IConvertible.

Definition at line 1931 of file DateTime.cs.

◆ ToDecimal()

decimal IConvertible. System.DateTime.ToDecimal ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1922 of file DateTime.cs.

◆ ToDouble()

double IConvertible. System.DateTime.ToDouble ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1912 of file DateTime.cs.

◆ ToFileTime()

long System.DateTime.ToFileTime ( )

Converts the value of the current T:System.DateTime object to a Windows file time.

Returns
The value of the current T:System.DateTime object expressed as a Windows file time.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting file time would represent a date and time before 12:00 midnight January 1, 1601 C.E. UTC.

Definition at line 1437 of file DateTime.cs.

◆ ToFileTimeUtc()

long System.DateTime.ToFileTimeUtc ( )

Converts the value of the current T:System.DateTime object to a Windows file time.

Returns
The value of the current T:System.DateTime object expressed as a Windows file time.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting file time would represent a date and time before 12:00 midnight January 1, 1601 C.E. UTC.

Definition at line 1446 of file DateTime.cs.

◆ ToInt16()

short IConvertible. System.DateTime.ToInt16 ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1842 of file DateTime.cs.

◆ ToInt32()

int IConvertible. System.DateTime.ToInt32 ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1862 of file DateTime.cs.

◆ ToInt64()

long IConvertible. System.DateTime.ToInt64 ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1882 of file DateTime.cs.

◆ ToLocalTime()

DateTime System.DateTime.ToLocalTime ( )

Converts the value of the current T:System.DateTime object to local time.

Returns
An object whose P:System.DateTime.Kind property is F:System.DateTimeKind.Local, and whose value is the local time equivalent to the value of the current T:System.DateTime object, or F:System.DateTime.MaxValue if the converted value is too large to be represented by a T:System.DateTime object, or F:System.DateTime.MinValue if the converted value is too small to be represented as a T:System.DateTime object.

Definition at line 1460 of file DateTime.cs.

◆ ToLongDateString()

string System.DateTime.ToLongDateString ( )

Converts the value of the current T:System.DateTime object to its equivalent long date string representation.

Returns
A string that contains the long date string representation of the current T:System.DateTime object.

Definition at line 1496 of file DateTime.cs.

◆ ToLongTimeString()

string System.DateTime.ToLongTimeString ( )

Converts the value of the current T:System.DateTime object to its equivalent long time string representation.

Returns
A string that contains the long time string representation of the current T:System.DateTime object.

Definition at line 1503 of file DateTime.cs.

◆ ToOADate()

double System.DateTime.ToOADate ( )

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

Returns
A double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance.
Exceptions
T:System.OverflowExceptionThe value of this instance cannot be represented as an OLE Automation Date.

Definition at line 1428 of file DateTime.cs.

◆ ToSByte()

sbyte IConvertible. System.DateTime.ToSByte ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1822 of file DateTime.cs.

◆ ToShortDateString()

string System.DateTime.ToShortDateString ( )

Converts the value of the current T:System.DateTime object to its equivalent short date string representation.

Returns
A string that contains the short date string representation of the current T:System.DateTime object.

Definition at line 1510 of file DateTime.cs.

◆ ToShortTimeString()

string System.DateTime.ToShortTimeString ( )

Converts the value of the current T:System.DateTime object to its equivalent short time string representation.

Returns
A string that contains the short time string representation of the current T:System.DateTime object.

Definition at line 1517 of file DateTime.cs.

◆ ToSingle()

float IConvertible. System.DateTime.ToSingle ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1902 of file DateTime.cs.

◆ ToString() [1/4]

override string System.DateTime.ToString ( )

Converts the value of the current T:System.DateTime object to its equivalent string representation using the formatting conventions of the current culture.

Returns
A string representation of the value of the current T:System.DateTime object.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe date and time is outside the range of dates supported by the calendar used by the current culture.

Definition at line 1526 of file DateTime.cs.

◆ ToString() [2/4]

string System.DateTime.ToString ( string  format)

Converts the value of the current T:System.DateTime object to its equivalent string representation using the specified format and the formatting conventions of the current culture.

Parameters
formatA standard or custom date and time format string (see Remarks).
Returns
A string representation of value of the current T:System.DateTime object as specified by format .
Exceptions
T:System.FormatExceptionThe length of format is 1, and it is not one of the format specifier characters defined for T:System.Globalization.DateTimeFormatInfo.-or- format does not contain a valid custom format pattern.
T:System.ArgumentOutOfRangeExceptionThe date and time is outside the range of dates supported by the calendar used by the current culture.

Definition at line 1538 of file DateTime.cs.

◆ ToString() [3/4]

string System.DateTime.ToString ( IFormatProvider  provider)

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

Parameters
providerAn object that supplies culture-specific formatting information.
Returns
A string representation of value of the current T:System.DateTime object as specified by provider .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe date and time is outside the range of dates supported by the calendar used by provider .

Implements System.IConvertible.

Definition at line 1548 of file DateTime.cs.

◆ ToString() [4/4]

string System.DateTime.ToString ( string  format,
IFormatProvider  provider 
)

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

Parameters
formatA standard or custom date and time format string.
providerAn object that supplies culture-specific formatting information.
Returns
A string representation of value of the current T:System.DateTime object as specified by format and provider .
Exceptions
T:System.FormatExceptionThe length of format is 1, and it is not one of the format specifier characters defined for T:System.Globalization.DateTimeFormatInfo.-or- format does not contain a valid custom format pattern.
T:System.ArgumentOutOfRangeExceptionThe date and time is outside the range of dates supported by the calendar used by provider .

Implements System.IFormattable.

Definition at line 1561 of file DateTime.cs.

◆ ToType()

object IConvertible. System.DateTime.ToType ( Type  type,
IFormatProvider  provider 
)

Converts the current T:System.DateTime object to an object of a specified type.

Parameters
typeThe desired type.
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
An object of the type specified by the type parameter, with a value equivalent to the current T:System.DateTime object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.InvalidCastExceptionThis conversion is not supported for the T:System.DateTime type.

Implements System.IConvertible.

Definition at line 1944 of file DateTime.cs.

◆ ToUInt16()

ushort IConvertible. System.DateTime.ToUInt16 ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1852 of file DateTime.cs.

◆ ToUInt32()

uint IConvertible. System.DateTime.ToUInt32 ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1872 of file DateTime.cs.

◆ ToUInt64()

ulong IConvertible. System.DateTime.ToUInt64 ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerAn object that implements the T:System.IFormatProvider interface. (This parameter is not used; specify null.)
Returns
The return value for this member is not used.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 1892 of file DateTime.cs.

◆ ToUniversalTime()

DateTime System.DateTime.ToUniversalTime ( )

Converts the value of the current T:System.DateTime object to Coordinated Universal Time (UTC).

Returns
An object whose P:System.DateTime.Kind property is F:System.DateTimeKind.Utc, and whose value is the UTC equivalent to the value of the current T:System.DateTime object, or F:System.DateTime.MaxValue if the converted value is too large to be represented by a T:System.DateTime object, or F:System.DateTime.MinValue if the converted value is too small to be represented by a T:System.DateTime object.

Definition at line 1569 of file DateTime.cs.

◆ TryParse() [1/2]

static bool System.DateTime.TryParse ( string  s,
out DateTime  result 
)
static

Converts the specified string representation of a date and time to its T:System.DateTime equivalent and returns a value that indicates whether the conversion succeeded.

Parameters
sA string containing a date and time to convert.
resultWhen this method returns, contains the T:System.DateTime value equivalent to the date and time contained in s , if the conversion succeeded, or F:System.DateTime.MinValue if the conversion failed. The conversion fails if the s parameter is null, is an empty string (""), or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.
Returns
true if the s parameter was converted successfully; otherwise, false.

Definition at line 1580 of file DateTime.cs.

◆ TryParse() [2/2]

static bool System.DateTime.TryParse ( string  s,
IFormatProvider  provider,
DateTimeStyles  styles,
out DateTime  result 
)
static

Converts the specified string representation of a date and time to its T:System.DateTime equivalent using the specified culture-specific format information and formatting style, and returns a value that indicates whether the conversion succeeded.

Parameters
sA string containing a date and time to convert.
providerAn object that supplies culture-specific formatting information about s .
stylesA bitwise combination of enumeration values 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 F:System.Globalization.DateTimeStyles.None.
resultWhen this method returns, contains the T:System.DateTime value equivalent to the date and time contained in s , if the conversion succeeded, or F:System.DateTime.MinValue if the conversion failed. The conversion fails if the s parameter is null, is an empty string (""), or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.
Returns
true if the s parameter was converted successfully; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyles is not a valid T:System.Globalization.DateTimeStyles value.-or- styles contains an invalid combination of T:System.Globalization.DateTimeStyles values (for example, both F:System.Globalization.DateTimeStyles.AssumeLocal and F:System.Globalization.DateTimeStyles.AssumeUniversal).
T:System.NotSupportedExceptionprovider is a neutral culture and cannot be used in a parsing operation.

Definition at line 1598 of file DateTime.cs.

◆ TryParseExact() [1/2]

static bool System.DateTime.TryParseExact ( string  s,
string  format,
IFormatProvider  provider,
DateTimeStyles  style,
out DateTime  result 
)
static

Converts the specified string representation of a date and time to its T:System.DateTime equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

Parameters
sA string containing a date and time to convert.
formatThe required format of s . See the Remarks section for more information.
providerAn object that supplies culture-specific formatting information about s .
styleA bitwise combination of one or more enumeration values that indicate the permitted format of s .
resultWhen this method returns, contains the T:System.DateTime value equivalent to the date and time contained in s , if the conversion succeeded, or F:System.DateTime.MinValue if the conversion failed. The conversion fails if either the s or format parameter is null, is an empty string, or does not contain a date and time that correspond to the pattern specified in format . This parameter is passed uninitialized.
Returns
true if s was converted successfully; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyles is not a valid T:System.Globalization.DateTimeStyles value.-or- styles contains an invalid combination of T:System.Globalization.DateTimeStyles values (for example, both F:System.Globalization.DateTimeStyles.AssumeLocal and F:System.Globalization.DateTimeStyles.AssumeUniversal).

Definition at line 1616 of file DateTime.cs.

◆ TryParseExact() [2/2]

static bool System.DateTime.TryParseExact ( string  s,
string []  formats,
IFormatProvider  provider,
DateTimeStyles  style,
out DateTime  result 
)
static

Converts the specified string representation of a date and time to its T:System.DateTime 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. The method returns a value that indicates whether the conversion succeeded.

Parameters
sA string that contains a date and time to convert.
formatsAn array of allowable formats of s . See the Remarks section for more information.
providerAn object that supplies culture-specific format information about s .
styleA bitwise combination of enumeration values that indicates the permitted format of s . A typical value to specify is F:System.Globalization.DateTimeStyles.None.
resultWhen this method returns, contains the T:System.DateTime value equivalent to the date and time contained in s , if the conversion succeeded, or F:System.DateTime.MinValue if the conversion failed. The conversion fails if s or formats is null, s or an element of formats is an empty string, or the format of s is not exactly as specified by at least one of the format patterns in formats . This parameter is passed uninitialized.
Returns
true if the s parameter was converted successfully; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyles is not a valid T:System.Globalization.DateTimeStyles value.-or- styles contains an invalid combination of T:System.Globalization.DateTimeStyles values (for example, both F:System.Globalization.DateTimeStyles.AssumeLocal and F:System.Globalization.DateTimeStyles.AssumeUniversal).

Definition at line 1634 of file DateTime.cs.

Member Data Documentation

◆ MaxValue

readonly DateTime System.DateTime.MaxValue = new DateTime(3155378975999999999L, DateTimeKind.Unspecified)
static

Represents the largest possible value of T:System.DateTime. This field is read-only.

Definition at line 113 of file DateTime.cs.

◆ MinValue

readonly DateTime System.DateTime.MinValue = new DateTime(0L, DateTimeKind.Unspecified)
static

Represents the smallest possible value of T:System.DateTime. This field is read-only.

Definition at line 109 of file DateTime.cs.

Property Documentation

◆ Date

DateTime System.DateTime.Date
get

Gets the date component of this instance.

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

Definition at line 147 of file DateTime.cs.

◆ Day

int System.DateTime.Day
get

Gets the day of the month represented by this instance.

Returns
The day component, expressed as a value between 1 and 31.

Definition at line 160 of file DateTime.cs.

◆ DayOfWeek

DayOfWeek System.DateTime.DayOfWeek
get

Gets the day of the week represented by this instance.

Returns
An enumerated constant that indicates the day of the week of this T:System.DateTime value.

Definition at line 172 of file DateTime.cs.

◆ DayOfYear

int System.DateTime.DayOfYear
get

Gets the day of the year represented by this instance.

Returns
The day of the year, expressed as a value between 1 and 366.

Definition at line 184 of file DateTime.cs.

◆ Hour

int System.DateTime.Hour
get

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

Returns
The hour component, expressed as a value between 0 and 23.

Definition at line 196 of file DateTime.cs.

◆ Kind

DateTimeKind System.DateTime.Kind
get

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

Returns
One of the enumeration values that indicates what the current time represents. The default is F:System.DateTimeKind.Unspecified.

Definition at line 208 of file DateTime.cs.

◆ Millisecond

int System.DateTime.Millisecond
get

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

Returns
The milliseconds component, expressed as a value between 0 and 999.

Definition at line 228 of file DateTime.cs.

◆ Minute

int System.DateTime.Minute
get

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

Returns
The minute component, expressed as a value between 0 and 59.

Definition at line 240 of file DateTime.cs.

◆ Month

int System.DateTime.Month
get

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

Returns
The month component, expressed as a value between 1 and 12.

Definition at line 252 of file DateTime.cs.

◆ Now

DateTime System.DateTime.Now
staticget

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

Returns
An object whose value is the current local date and time.

Definition at line 264 of file DateTime.cs.

◆ Second

int System.DateTime.Second
get

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

Returns
The seconds component, expressed as a value between 0 and 59.

Definition at line 303 of file DateTime.cs.

◆ Ticks

long System.DateTime.Ticks
get

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

Returns
The number of ticks that represent the date and time of this instance. The value is between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.

Definition at line 315 of file DateTime.cs.

◆ TimeOfDay

TimeSpan System.DateTime.TimeOfDay
get

Gets the time of day for this instance.

Returns
A time interval that represents the fraction of the day that has elapsed since midnight.

Definition at line 327 of file DateTime.cs.

◆ Today

DateTime System.DateTime.Today
staticget

Gets the current date.

Returns
An object that is set to today's date, with the time component set to 00:00:00.

Definition at line 339 of file DateTime.cs.

◆ UtcNow

DateTime System.DateTime.UtcNow
staticget

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

Returns
An object whose value is the current UTC date and time.

Definition at line 288 of file DateTime.cs.

◆ Year

int System.DateTime.Year
get

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

Returns
The year, between 1 and 9999.

Definition at line 351 of file DateTime.cs.


The documentation for this struct was generated from the following file: