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

Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Universal Time (UTC). More...

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

Public Member Functions

 DateTimeOffset (long ticks, TimeSpan offset)
 Initializes a new instance of the T:System.DateTimeOffset structure using the specified number of ticks and offset. More...
 
 DateTimeOffset (DateTime dateTime)
 Initializes a new instance of the T:System.DateTimeOffset structure using the specified T:System.DateTime value. More...
 
 DateTimeOffset (DateTime dateTime, TimeSpan offset)
 Initializes a new instance of the T:System.DateTimeOffset structure using the specified T:System.DateTime value and offset. More...
 
 DateTimeOffset (int year, int month, int day, int hour, int minute, int second, TimeSpan offset)
 Initializes a new instance of the T:System.DateTimeOffset structure using the specified year, month, day, hour, minute, second, and offset. More...
 
 DateTimeOffset (int year, int month, int day, int hour, int minute, int second, int millisecond, TimeSpan offset)
 Initializes a new instance of the T:System.DateTimeOffset structure using the specified year, month, day, hour, minute, second, millisecond, and offset. More...
 
 DateTimeOffset (int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar, TimeSpan offset)
 Initializes a new instance of the T:System.DateTimeOffset structure using the specified year, month, day, hour, minute, second, millisecond, and offset of a specified calendar. More...
 
DateTimeOffset ToOffset (TimeSpan offset)
 Converts the value of the current T:System.DateTimeOffset object to the date and time specified by an offset value. More...
 
DateTimeOffset Add (TimeSpan timeSpan)
 Returns a new T:System.DateTimeOffset object that adds a specified time interval to the value of this instance. More...
 
DateTimeOffset AddDays (double days)
 Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional days to the value of this instance. More...
 
DateTimeOffset AddHours (double hours)
 Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional hours to the value of this instance. More...
 
DateTimeOffset AddMilliseconds (double milliseconds)
 Returns a new T:System.DateTimeOffset object that adds a specified number of milliseconds to the value of this instance. More...
 
DateTimeOffset AddMinutes (double minutes)
 Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional minutes to the value of this instance. More...
 
DateTimeOffset AddMonths (int months)
 Returns a new T:System.DateTimeOffset object that adds a specified number of months to the value of this instance. More...
 
DateTimeOffset AddSeconds (double seconds)
 Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional seconds to the value of this instance. More...
 
DateTimeOffset AddTicks (long ticks)
 Returns a new T:System.DateTimeOffset object that adds a specified number of ticks to the value of this instance. More...
 
DateTimeOffset AddYears (int years)
 Returns a new T:System.DateTimeOffset object that adds a specified number of years to the value of this instance. More...
 
int IComparable. CompareTo (object obj)
 Compares the value of the current T:System.DateTimeOffset object with another object of the same type. More...
 
int CompareTo (DateTimeOffset other)
 Compares the current T:System.DateTimeOffset object to a specified T:System.DateTimeOffset object and indicates whether the current object is earlier than, the same as, or later than the second T:System.DateTimeOffset object. More...
 
override bool Equals (object obj)
 Determines whether a T:System.DateTimeOffset object represents the same point in time as a specified object. More...
 
bool Equals (DateTimeOffset other)
 Determines whether the current T:System.DateTimeOffset object represents the same point in time as a specified T:System.DateTimeOffset object. More...
 
bool EqualsExact (DateTimeOffset other)
 Determines whether the current T:System.DateTimeOffset object represents the same time and has the same offset as a specified T:System.DateTimeOffset object. More...
 
void IDeserializationCallback. OnDeserialization (object sender)
 Runs when the deserialization of an object has been completed. More...
 
void ISerializable. GetObjectData (SerializationInfo info, StreamingContext context)
 Populates a T:System.Runtime.Serialization.SerializationInfo object with the data required to serialize the current T:System.DateTimeOffset object. More...
 
override int GetHashCode ()
 Returns the hash code for the current T:System.DateTimeOffset object. More...
 
TimeSpan Subtract (DateTimeOffset value)
 Subtracts a T:System.DateTimeOffset value that represents a specific date and time from the current T:System.DateTimeOffset object. More...
 
DateTimeOffset Subtract (TimeSpan value)
 Subtracts a specified time interval from the current T:System.DateTimeOffset object. More...
 
long ToFileTime ()
 Converts the value of the current T:System.DateTimeOffset object to a Windows file time. More...
 
long ToUnixTimeSeconds ()
 Returns the number of seconds that have elapsed since 1970-01-01T00:00:00Z. More...
 
long ToUnixTimeMilliseconds ()
 Returns the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z. More...
 
DateTimeOffset ToLocalTime ()
 Converts the current T:System.DateTimeOffset object to a T:System.DateTimeOffset object that represents the local time. More...
 
internal DateTimeOffset ToLocalTime (bool throwOnOverflow)
 
override string ToString ()
 Converts the value of the current T:System.DateTimeOffset object to its equivalent string representation. More...
 
string ToString (string format)
 Converts the value of the current T:System.DateTimeOffset object to its equivalent string representation using the specified format. More...
 
string ToString (IFormatProvider formatProvider)
 Converts the value of the current T:System.DateTimeOffset object to its equivalent string representation using the specified culture-specific formatting information. More...
 
string ToString (string format, IFormatProvider formatProvider)
 Converts the value of the current T:System.DateTimeOffset object to its equivalent string representation using the specified format and culture-specific format information. More...
 
DateTimeOffset ToUniversalTime ()
 Converts the current T:System.DateTimeOffset object to a T:System.DateTimeOffset value that represents the Coordinated Universal Time (UTC). More...
 
- Public Member Functions inherited from System.IEquatable< DateTimeOffset >
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 (DateTimeOffset first, DateTimeOffset second)
 Compares two T:System.DateTimeOffset objects and indicates whether the first is earlier than the second, equal to the second, or later than the second. More...
 
static bool Equals (DateTimeOffset first, DateTimeOffset second)
 Determines whether two specified T:System.DateTimeOffset objects represent the same point in time. More...
 
static DateTimeOffset FromFileTime (long fileTime)
 Converts the specified Windows file time to an equivalent local time. More...
 
static DateTimeOffset FromUnixTimeSeconds (long seconds)
 Converts a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a T:System.DateTimeOffset value. More...
 
static DateTimeOffset FromUnixTimeMilliseconds (long milliseconds)
 Converts a Unix time expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z to a T:System.DateTimeOffset value. More...
 
static DateTimeOffset Parse (string input)
 Converts the specified string representation of a date, time, and offset to its T:System.DateTimeOffset equivalent. More...
 
static DateTimeOffset Parse (string input, IFormatProvider formatProvider)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified culture-specific format information. More...
 
static DateTimeOffset Parse (string input, IFormatProvider formatProvider, DateTimeStyles styles)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified culture-specific format information and formatting style. More...
 
static DateTimeOffset ParseExact (string input, string format, IFormatProvider formatProvider)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly. More...
 
static DateTimeOffset ParseExact (string input, string format, IFormatProvider formatProvider, DateTimeStyles styles)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. More...
 
static DateTimeOffset ParseExact (string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified formats, culture-specific format information, and style. The format of the string representation must match one of the specified formats exactly. More...
 
static bool TryParse (string input, out DateTimeOffset result)
 Tries to converts a specified string representation of a date and time to its T:System.DateTimeOffset equivalent, and returns a value that indicates whether the conversion succeeded. More...
 
static bool TryParse (string input, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result)
 Tries to convert a specified string representation of a date and time to its T:System.DateTimeOffset equivalent, and returns a value that indicates whether the conversion succeeded. More...
 
static bool TryParseExact (string input, string format, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. More...
 
static bool TryParseExact (string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result)
 Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match one of the specified formats exactly. More...
 
static implicit operator DateTimeOffset (DateTime dateTime)
 Defines an implicit conversion of a T:System.DateTime object to a T:System.DateTimeOffset object. More...
 
static DateTimeOffset operator+ (DateTimeOffset dateTimeOffset, TimeSpan timeSpan)
 Adds a specified time interval to a T:System.DateTimeOffset object that has a specified date and time, and yields a T:System.DateTimeOffset object that has new a date and time. More...
 
static DateTimeOffset operator - (DateTimeOffset dateTimeOffset, TimeSpan timeSpan)
 Subtracts a specified time interval from a specified date and time, and yields a new date and time. More...
 
static TimeSpan operator - (DateTimeOffset left, DateTimeOffset right)
 Subtracts one T:System.DateTimeOffset object from another and yields a time interval. More...
 
static bool operator== (DateTimeOffset left, DateTimeOffset right)
 Determines whether two specified T:System.DateTimeOffset objects represent the same point in time. More...
 
static bool operator != (DateTimeOffset left, DateTimeOffset right)
 Determines whether two specified T:System.DateTimeOffset objects refer to different points in time. More...
 
static bool operator< (DateTimeOffset left, DateTimeOffset right)
 Determines whether one specified T:System.DateTimeOffset object is less than a second specified T:System.DateTimeOffset object. More...
 
static bool operator<= (DateTimeOffset left, DateTimeOffset right)
 Determines whether one specified T:System.DateTimeOffset object is less than a second specified T:System.DateTimeOffset object. More...
 
static bool operator > (DateTimeOffset left, DateTimeOffset right)
 Determines whether one specified T:System.DateTimeOffset object is greater than (or later than) a second specified T:System.DateTimeOffset object. More...
 
static bool operator >= (DateTimeOffset left, DateTimeOffset right)
 Determines whether one specified T:System.DateTimeOffset object is greater than or equal to a second specified T:System.DateTimeOffset object. More...
 

Public Attributes

internal const long MaxOffset = 504000000000L
 
internal const long MinOffset = -504000000000L
 

Static Public Attributes

static readonly DateTimeOffset MinValue = new DateTimeOffset(0L, TimeSpan.Zero)
 Represents the earliest possible T:System.DateTimeOffset value. This field is read-only. More...
 
static readonly DateTimeOffset MaxValue = new DateTimeOffset(3155378975999999999L, TimeSpan.Zero)
 Represents the greatest possible value of T:System.DateTimeOffset. This field is read-only. More...
 

Properties

static DateTimeOffset Now [get]
 Gets a T:System.DateTimeOffset object that is set to the current date and time on the current computer, with the offset set to the local time's offset from Coordinated Universal Time (UTC). More...
 
static DateTimeOffset UtcNow [get]
 Gets a T:System.DateTimeOffset object whose date and time are set to the current Coordinated Universal Time (UTC) date and time and whose offset is F:System.TimeSpan.Zero. More...
 
DateTime DateTime [get]
 Gets a T:System.DateTime value that represents the date and time of the current T:System.DateTimeOffset object. More...
 
DateTime UtcDateTime [get]
 Gets a T:System.DateTime value that represents the Coordinated Universal Time (UTC) date and time of the current T:System.DateTimeOffset object. More...
 
DateTime LocalDateTime [get]
 Gets a T:System.DateTime value that represents the local date and time of the current T:System.DateTimeOffset object. More...
 
DateTime Date [get]
 Gets a T:System.DateTime value that represents the date component of the current T:System.DateTimeOffset object. More...
 
int Day [get]
 Gets the day of the month represented by the current T:System.DateTimeOffset object. More...
 
DayOfWeek DayOfWeek [get]
 Gets the day of the week represented by the current T:System.DateTimeOffset object. More...
 
int DayOfYear [get]
 Gets the day of the year represented by the current T:System.DateTimeOffset object. More...
 
int Hour [get]
 Gets the hour component of the time represented by the current T:System.DateTimeOffset object. More...
 
int Millisecond [get]
 Gets the millisecond component of the time represented by the current T:System.DateTimeOffset object. More...
 
int Minute [get]
 Gets the minute component of the time represented by the current T:System.DateTimeOffset object. More...
 
int Month [get]
 Gets the month component of the date represented by the current T:System.DateTimeOffset object. More...
 
TimeSpan Offset [get]
 Gets the time's offset from Coordinated Universal Time (UTC). More...
 
int Second [get]
 Gets the second component of the clock time represented by the current T:System.DateTimeOffset object. More...
 
long Ticks [get]
 Gets the number of ticks that represents the date and time of the current T:System.DateTimeOffset object in clock time. More...
 
long UtcTicks [get]
 Gets the number of ticks that represents the date and time of the current T:System.DateTimeOffset object in Coordinated Universal Time (UTC). More...
 
TimeSpan TimeOfDay [get]
 Gets the time of day for the current T:System.DateTimeOffset object. More...
 
int Year [get]
 Gets the year component of the date represented by the current T:System.DateTimeOffset object. More...
 

Detailed Description

Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Universal Time (UTC).

Definition at line 12 of file DateTimeOffset.cs.

Constructor & Destructor Documentation

◆ DateTimeOffset() [1/6]

System.DateTimeOffset.DateTimeOffset ( long  ticks,
TimeSpan  offset 
)

Initializes a new instance of the T:System.DateTimeOffset structure using the specified number of ticks and offset.

Parameters
ticksA date and time expressed as the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight on January 1, 0001.
offsetThe time's offset from Coordinated Universal Time (UTC).
Exceptions
T:System.ArgumentExceptionoffset is not specified in whole minutes.
T:System.ArgumentOutOfRangeExceptionThe P:System.DateTimeOffset.UtcDateTime property is earlier than F:System.DateTimeOffset.MinValue or later than F:System.DateTimeOffset.MaxValue.-or- ticks is less than DateTimeOffset.MinValue.Ticks or greater than DateTimeOffset.MaxValue.Ticks.-or- Offset s less than -14 hours or greater than 14 hours.

Definition at line 277 of file DateTimeOffset.cs.

◆ DateTimeOffset() [2/6]

System.DateTimeOffset.DateTimeOffset ( DateTime  dateTime)

Initializes a new instance of the T:System.DateTimeOffset structure using the specified T:System.DateTime value.

Parameters
dateTimeA date and time.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe Coordinated Universal Time (UTC) date and time that results from applying the offset is earlier than F:System.DateTimeOffset.MinValue.-or-The UTC date and time that results from applying the offset is later than F:System.DateTimeOffset.MaxValue.

Definition at line 288 of file DateTimeOffset.cs.

◆ DateTimeOffset() [3/6]

System.DateTimeOffset.DateTimeOffset ( DateTime  dateTime,
TimeSpan  offset 
)

Initializes a new instance of the T:System.DateTimeOffset structure using the specified T:System.DateTime value and offset.

Parameters
dateTimeA date and time.
offsetThe time's offset from Coordinated Universal Time (UTC).
Exceptions
T:System.ArgumentExceptiondateTime.Kind equals F:System.DateTimeKind.Utc and offset does not equal zero.-or- dateTime.Kind equals F:System.DateTimeKind.Local and offset does not equal the offset of the system's local time zone.-or- offset is not specified in whole minutes.
T:System.ArgumentOutOfRangeExceptionoffset is less than -14 hours or greater than 14 hours.-or- P:System.DateTimeOffset.UtcDateTime is less than F:System.DateTimeOffset.MinValue or greater than F:System.DateTimeOffset.MaxValue.

Definition at line 306 of file DateTimeOffset.cs.

◆ DateTimeOffset() [4/6]

System.DateTimeOffset.DateTimeOffset ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
TimeSpan  offset 
)

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

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).
offsetThe time's offset from Coordinated Universal Time (UTC).
Exceptions
T:System.ArgumentExceptionoffset does not represent whole minutes.
T:System.ArgumentOutOfRangeExceptionyear is less than one or greater than 9999.-or- month is less than one or greater than 12.-or- day is less than one or greater than the number of days in month .-or- hour is less than zero 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- offset is less than -14 hours or greater than 14 hours.-or-The P:System.DateTimeOffset.UtcDateTime property is earlier than F:System.DateTimeOffset.MinValue or later than F:System.DateTimeOffset.MaxValue.

Definition at line 342 of file DateTimeOffset.cs.

◆ DateTimeOffset() [5/6]

System.DateTimeOffset.DateTimeOffset ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond,
TimeSpan  offset 
)

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

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).
offsetThe time's offset from Coordinated Universal Time (UTC).
Exceptions
T:System.ArgumentExceptionoffset does not represent whole minutes.
T:System.ArgumentOutOfRangeExceptionyear is less than one or greater than 9999.-or- month is less than one or greater than 12.-or- day is less than one or greater than the number of days in month .-or- hour is less than zero 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.-or- offset is less than -14 or greater than 14.-or-The P:System.DateTimeOffset.UtcDateTime property is earlier than F:System.DateTimeOffset.MinValue or later than F:System.DateTimeOffset.MaxValue.

Definition at line 369 of file DateTimeOffset.cs.

◆ DateTimeOffset() [6/6]

System.DateTimeOffset.DateTimeOffset ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond,
Calendar  calendar,
TimeSpan  offset 
)

Initializes a new instance of the T:System.DateTimeOffset structure using the specified year, month, day, hour, minute, second, millisecond, and offset of a specified calendar.

Parameters
yearThe year.
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).
calendarThe calendar that is used to interpret year , month , and day .
offsetThe time's offset from Coordinated Universal Time (UTC).
Exceptions
T:System.ArgumentExceptionoffset does not represent whole minutes.
T:System.ArgumentNullExceptioncalendar cannot be null.
T:System.ArgumentOutOfRangeExceptionyear is less than the calendar parameter's MinSupportedDateTime.Year or greater than MaxSupportedDateTime.Year.-or- month is either less than or greater than the number of months in year in the calendar . -or- day is less than one or greater than the number of days in month .-or- hour is less than zero 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.-or- offset is less than -14 hours or greater than 14 hours.-or-The year , month , and day parameters cannot be represented as a date and time value.-or-The P:System.DateTimeOffset.UtcDateTime property is earlier than F:System.DateTimeOffset.MinValue or later than F:System.DateTimeOffset.MaxValue.

Definition at line 398 of file DateTimeOffset.cs.

Member Function Documentation

◆ Add()

DateTimeOffset System.DateTimeOffset.Add ( TimeSpan  timeSpan)

Returns a new T:System.DateTimeOffset object that adds a specified time interval to the value of this instance.

Parameters
timeSpanA T:System.TimeSpan object that represents a positive or a negative time interval.
Returns
An object whose value is the sum of the date and time represented by the current T:System.DateTimeOffset object and the time interval represented by timeSpan .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue.-or- The resulting T:System.DateTimeOffset value is greater than F:System.DateTimeOffset.MaxValue.

Definition at line 422 of file DateTimeOffset.cs.

◆ AddDays()

DateTimeOffset System.DateTimeOffset.AddDays ( double  days)

Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional days to the value of this instance.

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

Definition at line 432 of file DateTimeOffset.cs.

◆ AddHours()

DateTimeOffset System.DateTimeOffset.AddHours ( double  hours)

Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional hours to the value of this instance.

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

Definition at line 442 of file DateTimeOffset.cs.

◆ AddMilliseconds()

DateTimeOffset System.DateTimeOffset.AddMilliseconds ( double  milliseconds)

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

Parameters
millisecondsA number of whole and fractional milliseconds. The number can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by the current T:System.DateTimeOffset object and the number of whole milliseconds represented by milliseconds .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue.-or- The resulting T:System.DateTimeOffset value is greater than F:System.DateTimeOffset.MaxValue.

Definition at line 452 of file DateTimeOffset.cs.

◆ AddMinutes()

DateTimeOffset System.DateTimeOffset.AddMinutes ( double  minutes)

Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional minutes to the value of this instance.

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

Definition at line 462 of file DateTimeOffset.cs.

◆ AddMonths()

DateTimeOffset System.DateTimeOffset.AddMonths ( int  months)

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

Parameters
monthsA number of whole months. The number can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by the current T:System.DateTimeOffset object and the number of months represented by months .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue.-or- The resulting T:System.DateTimeOffset value is greater than F:System.DateTimeOffset.MaxValue.

Definition at line 472 of file DateTimeOffset.cs.

◆ AddSeconds()

DateTimeOffset System.DateTimeOffset.AddSeconds ( double  seconds)

Returns a new T:System.DateTimeOffset object that adds a specified number of whole and fractional seconds to the value of this instance.

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

Definition at line 482 of file DateTimeOffset.cs.

◆ AddTicks()

DateTimeOffset System.DateTimeOffset.AddTicks ( long  ticks)

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

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

Definition at line 492 of file DateTimeOffset.cs.

◆ AddYears()

DateTimeOffset System.DateTimeOffset.AddYears ( int  years)

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

Parameters
yearsA number of years. The number can be negative or positive.
Returns
An object whose value is the sum of the date and time represented by the current T:System.DateTimeOffset object and the number of years represented by years .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue.-or- The resulting T:System.DateTimeOffset value is greater than F:System.DateTimeOffset.MaxValue.

Definition at line 502 of file DateTimeOffset.cs.

◆ Compare()

static int System.DateTimeOffset.Compare ( DateTimeOffset  first,
DateTimeOffset  second 
)
static

Compares two T:System.DateTimeOffset objects and indicates whether the first is earlier than the second, equal to the second, or later than the second.

Parameters
firstThe first object to compare.
secondThe second object to compare.
Returns
A signed integer that indicates whether the value of the first parameter is earlier than, later than, or the same time as the value of the second parameter, as the following table shows.Return valueMeaningLess than zero first is earlier than second .Zero first is equal to second .Greater than zero first is later than second .

Definition at line 515 of file DateTimeOffset.cs.

◆ CompareTo() [1/2]

int IComparable. System.DateTimeOffset.CompareTo ( object  obj)

Compares the value of the current T:System.DateTimeOffset object with another object of the same type.

Parameters
objThe object to compare with the current T:System.DateTimeOffset object.
Returns
A 32-bit signed integer that indicates whether the current T:System.DateTimeOffset object is less than, equal to, or greater than obj . The return values of the method are interpreted as follows:Return ValueDescriptionLess than zeroThe current T:System.DateTimeOffset object is less than (earlier than) obj .ZeroThe current T:System.DateTimeOffset object is equal to (the same point in time as) obj .Greater than zeroThe current T:System.DateTimeOffset object is greater than (later than) obj .

Definition at line 524 of file DateTimeOffset.cs.

◆ CompareTo() [2/2]

int System.DateTimeOffset.CompareTo ( DateTimeOffset  other)

Compares the current T:System.DateTimeOffset object to a specified T:System.DateTimeOffset object and indicates whether the current object is earlier than, the same as, or later than the second T:System.DateTimeOffset object.

Parameters
otherAn object to compare with the current T:System.DateTimeOffset object.
Returns
A signed integer that indicates the relationship between the current T:System.DateTimeOffset object and other , as the following table shows.Return ValueDescriptionLess than zeroThe current T:System.DateTimeOffset object is earlier than other .ZeroThe current T:System.DateTimeOffset object is the same as other .Greater than zero.The current T:System.DateTimeOffset object is later than other .

Definition at line 551 of file DateTimeOffset.cs.

◆ Equals() [1/3]

override bool System.DateTimeOffset.Equals ( object  obj)

Determines whether a T:System.DateTimeOffset object represents the same point in time as a specified object.

Parameters
objThe object to compare to the current T:System.DateTimeOffset object.
Returns
true if the obj parameter is a T:System.DateTimeOffset object and represents the same point in time as the current T:System.DateTimeOffset object; otherwise, false.

Definition at line 571 of file DateTimeOffset.cs.

◆ Equals() [2/3]

bool System.DateTimeOffset.Equals ( DateTimeOffset  other)

Determines whether the current T:System.DateTimeOffset object represents the same point in time as a specified T:System.DateTimeOffset object.

Parameters
otherAn object to compare to the current T:System.DateTimeOffset object.
Returns
true if both T:System.DateTimeOffset objects have the same P:System.DateTimeOffset.UtcDateTime value; otherwise, false.

Definition at line 585 of file DateTimeOffset.cs.

◆ Equals() [3/3]

static bool System.DateTimeOffset.Equals ( DateTimeOffset  first,
DateTimeOffset  second 
)
static

Determines whether two specified T:System.DateTimeOffset objects represent the same point in time.

Parameters
firstThe first object to compare.
secondThe second object to compare.
Returns
true if the two T:System.DateTimeOffset objects have the same P:System.DateTimeOffset.UtcDateTime value; otherwise, false.

Definition at line 610 of file DateTimeOffset.cs.

◆ EqualsExact()

bool System.DateTimeOffset.EqualsExact ( DateTimeOffset  other)

Determines whether the current T:System.DateTimeOffset object represents the same time and has the same offset as a specified T:System.DateTimeOffset object.

Parameters
otherThe object to compare to the current T:System.DateTimeOffset object.
Returns
true if the current T:System.DateTimeOffset object and other have the same date and time value and the same P:System.DateTimeOffset.Offset value; otherwise, false.

Definition at line 595 of file DateTimeOffset.cs.

◆ FromFileTime()

static DateTimeOffset System.DateTimeOffset.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 date and time of fileTime with the offset set to the local time offset.
Exceptions
T:System.ArgumentOutOfRangeExceptionfiletime is less than zero.-or- filetime is greater than DateTimeOffset.MaxValue.Ticks.

Definition at line 622 of file DateTimeOffset.cs.

◆ FromUnixTimeMilliseconds()

static DateTimeOffset System.DateTimeOffset.FromUnixTimeMilliseconds ( long  milliseconds)
static

Converts a Unix time expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z to a T:System.DateTimeOffset value.

Parameters
millisecondsA Unix time, expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC). For Unix times before this date, its value is negative.
Returns
A date and time value that represents the same moment in time as the Unix time.
Exceptions
T:System.ArgumentOutOfRangeExceptionmilliseconds is less than -62,135,596,800,000. -or- milliseconds is greater than 253,402,300,799,999.

Definition at line 651 of file DateTimeOffset.cs.

◆ FromUnixTimeSeconds()

static DateTimeOffset System.DateTimeOffset.FromUnixTimeSeconds ( long  seconds)
static

Converts a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a T:System.DateTimeOffset value.

Parameters
secondsA Unix time, expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC). For Unix times before this date, its value is negative.
Returns
A date and time value that represents the same moment in time as the Unix time.
Exceptions
T:System.ArgumentOutOfRangeExceptionseconds is less than -62,135,596,800. -or- seconds is greater than 253,402,300,799.

Definition at line 634 of file DateTimeOffset.cs.

◆ GetHashCode()

override int System.DateTimeOffset.GetHashCode ( )

Returns the hash code for the current T:System.DateTimeOffset object.

Returns
A 32-bit signed integer hash code.

Definition at line 704 of file DateTimeOffset.cs.

◆ GetObjectData()

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

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

Parameters
infoThe object to populate with data.
contextThe destination for this serialization (see T:System.Runtime.Serialization.StreamingContext).
Exceptions
T:System.ArgumentNullExceptionThe info parameter is null.

Implements System.Runtime.Serialization.ISerializable.

Definition at line 681 of file DateTimeOffset.cs.

◆ OnDeserialization()

void IDeserializationCallback. System.DateTimeOffset.OnDeserialization ( object  sender)

Runs when the deserialization of an object has been completed.

Parameters
senderThe object that initiated the callback. The functionality for this parameter is not currently implemented.

Implements System.Runtime.Serialization.IDeserializationCallback.

Definition at line 663 of file DateTimeOffset.cs.

◆ operator !=()

static bool System.DateTimeOffset.operator != ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Determines whether two specified T:System.DateTimeOffset objects refer to different points in time.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if left and right do not have the same P:System.DateTimeOffset.UtcDateTime value; otherwise, false.

Definition at line 1124 of file DateTimeOffset.cs.

◆ operator -() [1/2]

static DateTimeOffset System.DateTimeOffset.operator - ( DateTimeOffset  dateTimeOffset,
TimeSpan  timeSpan 
)
static

Subtracts a specified time interval from a specified date and time, and yields a new date and time.

Parameters
dateTimeOffsetThe date and time object to subtract from.
timeSpanThe time interval to subtract.
Returns
An object that is equal to the value of dateTimeOffset minus timeSpan .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue or greater than F:System.DateTimeOffset.MaxValue.

Definition at line 1092 of file DateTimeOffset.cs.

◆ operator -() [2/2]

static TimeSpan System.DateTimeOffset.operator - ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Subtracts one T:System.DateTimeOffset object from another and yields a time interval.

Parameters
leftThe minuend.
rightThe subtrahend.
Returns
An object that represents the difference between left and right .

Definition at line 1102 of file DateTimeOffset.cs.

◆ operator >()

static bool System.DateTimeOffset.operator > ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Determines whether one specified T:System.DateTimeOffset object is greater than (or later than) a second specified T:System.DateTimeOffset object.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if the P:System.DateTimeOffset.UtcDateTime value of left is later than the P:System.DateTimeOffset.UtcDateTime value of right ; otherwise, false.

Definition at line 1157 of file DateTimeOffset.cs.

◆ operator >=()

static bool System.DateTimeOffset.operator >= ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Determines whether one specified T:System.DateTimeOffset object is greater than or equal to a second specified T:System.DateTimeOffset object.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if the P:System.DateTimeOffset.UtcDateTime value of left is the same as or later than the P:System.DateTimeOffset.UtcDateTime value of right ; otherwise, false.

Definition at line 1168 of file DateTimeOffset.cs.

◆ operator DateTimeOffset()

static implicit System.DateTimeOffset.operator DateTimeOffset ( DateTime  dateTime)
static

Defines an implicit conversion of a T:System.DateTime object to a T:System.DateTimeOffset object.

Parameters
dateTimeThe object to convert.
Returns
The converted object.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe Coordinated Universal Time (UTC) date and time that results from applying the offset is earlier than F:System.DateTimeOffset.MinValue.-or-The UTC date and time that results from applying the offset is later than F:System.DateTimeOffset.MaxValue.

Definition at line 1070 of file DateTimeOffset.cs.

◆ operator+()

static DateTimeOffset System.DateTimeOffset.operator+ ( DateTimeOffset  dateTimeOffset,
TimeSpan  timeSpan 
)
static

Adds a specified time interval to a T:System.DateTimeOffset object that has a specified date and time, and yields a T:System.DateTimeOffset object that has new a date and time.

Parameters
dateTimeOffsetThe object to add the time interval to.
timeSpanThe time interval to add.
Returns
An object whose value is the sum of the values of dateTimeTz and timeSpan .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue.-or- The resulting T:System.DateTimeOffset value is greater than F:System.DateTimeOffset.MaxValue.

Definition at line 1081 of file DateTimeOffset.cs.

◆ operator<()

static bool System.DateTimeOffset.operator< ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Determines whether one specified T:System.DateTimeOffset object is less than a second specified T:System.DateTimeOffset object.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if the P:System.DateTimeOffset.UtcDateTime value of left is earlier than the P:System.DateTimeOffset.UtcDateTime value of right ; otherwise, false.

Definition at line 1135 of file DateTimeOffset.cs.

◆ operator<=()

static bool System.DateTimeOffset.operator<= ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Determines whether one specified T:System.DateTimeOffset object is less than a second specified T:System.DateTimeOffset object.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if the P:System.DateTimeOffset.UtcDateTime value of left is earlier than the P:System.DateTimeOffset.UtcDateTime value of right ; otherwise, false.

Definition at line 1146 of file DateTimeOffset.cs.

◆ operator==()

static bool System.DateTimeOffset.operator== ( DateTimeOffset  left,
DateTimeOffset  right 
)
static

Determines whether two specified T:System.DateTimeOffset objects represent the same point in time.

Parameters
leftThe first object to compare.
rightThe second object to compare.
Returns
true if both T:System.DateTimeOffset objects have the same P:System.DateTimeOffset.UtcDateTime value; otherwise, false.

Definition at line 1113 of file DateTimeOffset.cs.

◆ Parse() [1/3]

static DateTimeOffset System.DateTimeOffset.Parse ( string  input)
static

Converts the specified string representation of a date, time, and offset to its T:System.DateTimeOffset equivalent.

Parameters
inputA string that contains a date and time to convert.
Returns
An object that is equivalent to the date and time that is contained in input .
Exceptions
T:System.ArgumentExceptionThe offset is greater than 14 hours or less than -14 hours.
T:System.ArgumentNullExceptioninput is null.
T:System.FormatExceptioninput does not contain a valid string representation of a date and time.-or- input contains the string representation of an offset value without a date or time.

Definition at line 719 of file DateTimeOffset.cs.

◆ Parse() [2/3]

static DateTimeOffset System.DateTimeOffset.Parse ( string  input,
IFormatProvider  formatProvider 
)
static

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

Parameters
inputA string that contains a date and time to convert.
formatProviderAn object that provides culture-specific format information about input .
Returns
An object that is equivalent to the date and time that is contained in input , as specified by formatProvider .
Exceptions
T:System.ArgumentExceptionThe offset is greater than 14 hours or less than -14 hours.
T:System.ArgumentNullExceptioninput is null.
T:System.FormatExceptioninput does not contain a valid string representation of a date and time.-or- input contains the string representation of an offset value without a date or time.

Definition at line 736 of file DateTimeOffset.cs.

◆ Parse() [3/3]

static DateTimeOffset System.DateTimeOffset.Parse ( string  input,
IFormatProvider  formatProvider,
DateTimeStyles  styles 
)
static

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

Parameters
inputA string that contains a date and time to convert.
formatProviderAn object that provides culture-specific format information about input .
stylesA bitwise combination of enumeration values that indicates the permitted format of input . A typical value to specify is F:System.Globalization.DateTimeStyles.None.
Returns
An object that is equivalent to the date and time that is contained in input as specified by formatProvider and styles .
Exceptions
T:System.ArgumentExceptionThe offset is greater than 14 hours or less than -14 hours.-or- styles is not a valid T:System.Globalization.DateTimeStyles value.-or- styles includes an unsupported T:System.Globalization.DateTimeStyles value.-or- styles includes T:System.Globalization.DateTimeStyles values that cannot be used together.
T:System.ArgumentNullExceptioninput is null.
T:System.FormatExceptioninput does not contain a valid string representation of a date and time.-or- input contains the string representation of an offset value without a date or time.

Definition at line 756 of file DateTimeOffset.cs.

◆ ParseExact() [1/3]

static DateTimeOffset System.DateTimeOffset.ParseExact ( string  input,
string  format,
IFormatProvider  formatProvider 
)
static

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

Parameters
inputA string that contains a date and time to convert.
formatA format specifier that defines the expected format of input .
formatProviderAn object that supplies culture-specific formatting information about input .
Returns
An object that is equivalent to the date and time that is contained in input as specified by format and formatProvider .
Exceptions
T:System.ArgumentExceptionThe offset is greater than 14 hours or less than -14 hours.
T:System.ArgumentNullExceptioninput is null.-or- format is null.
T:System.FormatExceptioninput is an empty string ("").-or- input does not contain a valid string representation of a date and time.-or- format is an empty string.-or- The hour component and the AM/PM designator in input do not agree.

Definition at line 778 of file DateTimeOffset.cs.

◆ ParseExact() [2/3]

static DateTimeOffset System.DateTimeOffset.ParseExact ( string  input,
string  format,
IFormatProvider  formatProvider,
DateTimeStyles  styles 
)
static

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

Parameters
inputA string that contains a date and time to convert.
formatA format specifier that defines the expected format of input .
formatProviderAn object that supplies culture-specific formatting information about input .
stylesA bitwise combination of enumeration values that indicates the permitted format of input .
Returns
An object that is equivalent to the date and time that is contained in the input parameter, as specified by the format , formatProvider , and styles parameters.
Exceptions
T:System.ArgumentExceptionThe offset is greater than 14 hours or less than -14 hours.-or-The styles parameter includes an unsupported value.-or-The styles parameter contains T:System.Globalization.DateTimeStyles values that cannot be used together.
T:System.ArgumentNullExceptioninput is null.-or- format is null.
T:System.FormatExceptioninput is an empty string ("").-or- input does not contain a valid string representation of a date and time.-or- format is an empty string.-or- The hour component and the AM/PM designator in input do not agree.

Definition at line 799 of file DateTimeOffset.cs.

◆ ParseExact() [3/3]

static DateTimeOffset System.DateTimeOffset.ParseExact ( string  input,
string []  formats,
IFormatProvider  formatProvider,
DateTimeStyles  styles 
)
static

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

Parameters
inputA string that contains a date and time to convert.
formatsAn array of format specifiers that define the expected formats of input .
formatProviderAn object that supplies culture-specific formatting information about input .
stylesA bitwise combination of enumeration values that indicates the permitted format of input .
Returns
An object that is equivalent to the date and time that is contained in the input parameter, as specified by the formats , formatProvider , and styles parameters.
Exceptions
T:System.ArgumentExceptionThe offset is greater than 14 hours or less than -14 hours.-or- styles includes an unsupported value.-or-The styles parameter contains T:System.Globalization.DateTimeStyles values that cannot be used together.
T:System.ArgumentNullExceptioninput is null.
T:System.FormatExceptioninput is an empty string ("").-or- input does not contain a valid string representation of a date and time.-or-No element of formats contains a valid format specifier.-or- The hour component and the AM/PM designator in input do not agree.

Definition at line 821 of file DateTimeOffset.cs.

◆ Subtract() [1/2]

TimeSpan System.DateTimeOffset.Subtract ( DateTimeOffset  value)

Subtracts a T:System.DateTimeOffset value that represents a specific date and time from the current T:System.DateTimeOffset object.

Parameters
valueAn object that represents the value to subtract.
Returns
An object that specifies the interval between the two T:System.DateTimeOffset objects.

Definition at line 832 of file DateTimeOffset.cs.

◆ Subtract() [2/2]

DateTimeOffset System.DateTimeOffset.Subtract ( TimeSpan  value)

Subtracts a specified time interval from the current T:System.DateTimeOffset object.

Parameters
valueThe time interval to subtract.
Returns
An object that is equal to the date and time represented by the current T:System.DateTimeOffset object, minus the time interval represented by value .
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting T:System.DateTimeOffset value is less than F:System.DateTimeOffset.MinValue.-or- The resulting T:System.DateTimeOffset value is greater than F:System.DateTimeOffset.MaxValue.

Definition at line 842 of file DateTimeOffset.cs.

◆ ToFileTime()

long System.DateTimeOffset.ToFileTime ( )

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

Returns
The value of the current T:System.DateTimeOffset object, expressed as a Windows file time.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe resulting file time would represent a date and time before midnight on January 1, 1601 C.E. Coordinated Universal Time (UTC).

Definition at line 851 of file DateTimeOffset.cs.

◆ ToLocalTime()

DateTimeOffset System.DateTimeOffset.ToLocalTime ( )

Converts the current T:System.DateTimeOffset object to a T:System.DateTimeOffset object that represents the local time.

Returns
An object that represents the date and time of the current T:System.DateTimeOffset object converted to local time.

Definition at line 877 of file DateTimeOffset.cs.

◆ ToOffset()

DateTimeOffset System.DateTimeOffset.ToOffset ( TimeSpan  offset)

Converts the value of the current T:System.DateTimeOffset object to the date and time specified by an offset value.

Parameters
offsetThe offset to convert the T:System.DateTimeOffset value to.
Returns
An object that is equal to the original T:System.DateTimeOffset object (that is, their M:System.DateTimeOffset.ToUniversalTime methods return identical points in time) but whose P:System.DateTimeOffset.Offset property is set to offset .
Exceptions
T:System.ArgumentExceptionThe resulting T:System.DateTimeOffset object has a P:System.DateTimeOffset.DateTime value earlier than F:System.DateTimeOffset.MinValue.-or-The resulting T:System.DateTimeOffset object has a P:System.DateTimeOffset.DateTime value later than F:System.DateTimeOffset.MaxValue.
T:System.ArgumentOutOfRangeExceptionoffset is less than -14 hours.-or- offset is greater than 14 hours.

Definition at line 412 of file DateTimeOffset.cs.

◆ ToString() [1/4]

override string System.DateTimeOffset.ToString ( )

Converts the value of the current T:System.DateTimeOffset object to its equivalent string representation.

Returns
A string representation of a T:System.DateTimeOffset object that includes the offset appended at the end of the string.
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 891 of file DateTimeOffset.cs.

◆ ToString() [2/4]

string System.DateTimeOffset.ToString ( string  format)

Converts the value of the current T:System.DateTimeOffset object to its equivalent string representation using the specified format.

Parameters
formatA format string.
Returns
A string representation of the value of the current T:System.DateTimeOffset object, as specified by format .
Exceptions
T:System.FormatExceptionThe length of format is one, and it is not one of the standard 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 903 of file DateTimeOffset.cs.

◆ ToString() [3/4]

string System.DateTimeOffset.ToString ( IFormatProvider  formatProvider)

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

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

Definition at line 913 of file DateTimeOffset.cs.

◆ ToString() [4/4]

string System.DateTimeOffset.ToString ( string  format,
IFormatProvider  formatProvider 
)

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

Parameters
formatA format string.
formatProviderAn object that supplies culture-specific formatting information.
Returns
A string representation of the value of the current T:System.DateTimeOffset object, as specified by format and provider .
Exceptions
T:System.FormatExceptionThe length of format is one, and it is not one of the standard 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 formatProvider .

Implements System.IFormattable.

Definition at line 926 of file DateTimeOffset.cs.

◆ ToUniversalTime()

DateTimeOffset System.DateTimeOffset.ToUniversalTime ( )

Converts the current T:System.DateTimeOffset object to a T:System.DateTimeOffset value that represents the Coordinated Universal Time (UTC).

Returns
An object that represents the date and time of the current T:System.DateTimeOffset object converted to Coordinated Universal Time (UTC).

Definition at line 934 of file DateTimeOffset.cs.

◆ ToUnixTimeMilliseconds()

long System.DateTimeOffset.ToUnixTimeMilliseconds ( )

Returns the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.

Returns
The number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.

Definition at line 868 of file DateTimeOffset.cs.

◆ ToUnixTimeSeconds()

long System.DateTimeOffset.ToUnixTimeSeconds ( )

Returns the number of seconds that have elapsed since 1970-01-01T00:00:00Z.

Returns
The number of seconds that have elapsed since 1970-01-01T00:00:00Z.

Definition at line 859 of file DateTimeOffset.cs.

◆ TryParse() [1/2]

static bool System.DateTimeOffset.TryParse ( string  input,
out DateTimeOffset  result 
)
static

Tries to converts a specified string representation of a date and time to its T:System.DateTimeOffset equivalent, and returns a value that indicates whether the conversion succeeded.

Parameters
inputA string that contains a date and time to convert.
resultWhen the method returns, contains the T:System.DateTimeOffset equivalent to the date and time of input , if the conversion succeeded, or F:System.DateTimeOffset.MinValue, if the conversion failed. The conversion fails if the input parameter is null or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.
Returns
true if the input parameter is successfully converted; otherwise, false.

Definition at line 945 of file DateTimeOffset.cs.

◆ TryParse() [2/2]

static bool System.DateTimeOffset.TryParse ( string  input,
IFormatProvider  formatProvider,
DateTimeStyles  styles,
out DateTimeOffset  result 
)
static

Tries to convert a specified string representation of a date and time to its T:System.DateTimeOffset equivalent, and returns a value that indicates whether the conversion succeeded.

Parameters
inputA string that contains a date and time to convert.
formatProviderAn object that provides culture-specific formatting information about input .
stylesA bitwise combination of enumeration values that indicates the permitted format of input .
resultWhen the method returns, contains the T:System.DateTimeOffset value equivalent to the date and time of input , if the conversion succeeded, or F:System.DateTimeOffset.MinValue, if the conversion failed. The conversion fails if the input parameter is null or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.
Returns
true if the input parameter is successfully converted; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyles includes an undefined T:System.Globalization.DateTimeStyles value.-or- F:System.Globalization.DateTimeStyles.NoCurrentDateDefault is not supported.-or- styles includes mutually exclusive T:System.Globalization.DateTimeStyles values.

Definition at line 966 of file DateTimeOffset.cs.

◆ TryParseExact() [1/2]

static bool System.DateTimeOffset.TryParseExact ( string  input,
string  format,
IFormatProvider  formatProvider,
DateTimeStyles  styles,
out DateTimeOffset  result 
)
static

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

Parameters
inputA string that contains a date and time to convert.
formatA format specifier that defines the required format of input .
formatProviderAn object that supplies culture-specific formatting information about input .
stylesA bitwise combination of enumeration values that indicates the permitted format of input. A typical value to specify is None.
resultWhen the method returns, contains the T:System.DateTimeOffset equivalent to the date and time of input , if the conversion succeeded, or F:System.DateTimeOffset.MinValue, if the conversion failed. The conversion fails if the input parameter is null, or does not contain a valid string representation of a date and time in the expected format defined by format and provider . This parameter is passed uninitialized.
Returns
true if the input parameter is successfully converted; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyles includes an undefined T:System.Globalization.DateTimeStyles value.-or- F:System.Globalization.DateTimeStyles.NoCurrentDateDefault is not supported.-or- styles includes mutually exclusive T:System.Globalization.DateTimeStyles values.

Definition at line 989 of file DateTimeOffset.cs.

◆ TryParseExact() [2/2]

static bool System.DateTimeOffset.TryParseExact ( string  input,
string []  formats,
IFormatProvider  formatProvider,
DateTimeStyles  styles,
out DateTimeOffset  result 
)
static

Converts the specified string representation of a date and time to its T:System.DateTimeOffset equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match one of the specified formats exactly.

Parameters
inputA string that contains a date and time to convert.
formatsAn array that defines the expected formats of input .
formatProviderAn object that supplies culture-specific formatting information about input .
stylesA bitwise combination of enumeration values that indicates the permitted format of input. A typical value to specify is None.
resultWhen the method returns, contains the T:System.DateTimeOffset equivalent to the date and time of input , if the conversion succeeded, or F:System.DateTimeOffset.MinValue, if the conversion failed. The conversion fails if the input does not contain a valid string representation of a date and time, or does not contain the date and time in the expected format defined by format , or if formats is null. This parameter is passed uninitialized.
Returns
true if the input parameter is successfully converted; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyles includes an undefined T:System.Globalization.DateTimeStyles value.-or- F:System.Globalization.DateTimeStyles.NoCurrentDateDefault is not supported.-or- styles includes mutually exclusive T:System.Globalization.DateTimeStyles values.

Definition at line 1012 of file DateTimeOffset.cs.

Member Data Documentation

◆ MaxValue

readonly DateTimeOffset System.DateTimeOffset.MaxValue = new DateTimeOffset(3155378975999999999L, TimeSpan.Zero)
static

Represents the greatest possible value of T:System.DateTimeOffset. This field is read-only.

Exceptions
T:System.ArgumentOutOfRangeExceptionF:System.DateTime.MaxValue is outside the range of the current or specified culture's default calendar.

Definition at line 32 of file DateTimeOffset.cs.

◆ MinValue

readonly DateTimeOffset System.DateTimeOffset.MinValue = new DateTimeOffset(0L, TimeSpan.Zero)
static

Represents the earliest possible T:System.DateTimeOffset value. This field is read-only.

Definition at line 26 of file DateTimeOffset.cs.

Property Documentation

◆ Date

DateTime System.DateTimeOffset.Date
get

Gets a T:System.DateTime value that represents the date component of the current T:System.DateTimeOffset object.

Returns
A T:System.DateTime value that represents the date component of the current T:System.DateTimeOffset object.

Definition at line 104 of file DateTimeOffset.cs.

◆ DateTime

DateTime System.DateTimeOffset.DateTime
get

Gets a T:System.DateTime value that represents the date and time of the current T:System.DateTimeOffset object.

Returns
The date and time of the current T:System.DateTimeOffset object.

Definition at line 66 of file DateTimeOffset.cs.

◆ Day

int System.DateTimeOffset.Day
get

Gets the day of the month represented by the current T:System.DateTimeOffset object.

Returns
The day component of the current T:System.DateTimeOffset object, expressed as a value between 1 and 31.

Definition at line 116 of file DateTimeOffset.cs.

◆ DayOfWeek

DayOfWeek System.DateTimeOffset.DayOfWeek
get

Gets the day of the week represented by the current T:System.DateTimeOffset object.

Returns
One of the enumeration values that indicates the day of the week of the current T:System.DateTimeOffset object.

Definition at line 128 of file DateTimeOffset.cs.

◆ DayOfYear

int System.DateTimeOffset.DayOfYear
get

Gets the day of the year represented by the current T:System.DateTimeOffset object.

Returns
The day of the year of the current T:System.DateTimeOffset object, expressed as a value between 1 and 366.

Definition at line 140 of file DateTimeOffset.cs.

◆ Hour

int System.DateTimeOffset.Hour
get

Gets the hour component of the time represented by the current T:System.DateTimeOffset object.

Returns
The hour component of the current T:System.DateTimeOffset object. This property uses a 24-hour clock; the value ranges from 0 to 23.

Definition at line 152 of file DateTimeOffset.cs.

◆ LocalDateTime

DateTime System.DateTimeOffset.LocalDateTime
get

Gets a T:System.DateTime value that represents the local date and time of the current T:System.DateTimeOffset object.

Returns
The local date and time of the current T:System.DateTimeOffset object.

Definition at line 90 of file DateTimeOffset.cs.

◆ Millisecond

int System.DateTimeOffset.Millisecond
get

Gets the millisecond component of the time represented by the current T:System.DateTimeOffset object.

Returns
The millisecond component of the current T:System.DateTimeOffset object, expressed as an integer between 0 and 999.

Definition at line 164 of file DateTimeOffset.cs.

◆ Minute

int System.DateTimeOffset.Minute
get

Gets the minute component of the time represented by the current T:System.DateTimeOffset object.

Returns
The minute component of the current T:System.DateTimeOffset object, expressed as an integer between 0 and 59.

Definition at line 176 of file DateTimeOffset.cs.

◆ Month

int System.DateTimeOffset.Month
get

Gets the month component of the date represented by the current T:System.DateTimeOffset object.

Returns
The month component of the current T:System.DateTimeOffset object, expressed as an integer between 1 and 12.

Definition at line 188 of file DateTimeOffset.cs.

◆ Now

DateTimeOffset System.DateTimeOffset.Now
staticget

Gets a T:System.DateTimeOffset object that is set to the current date and time on the current computer, with the offset set to the local time's offset from Coordinated Universal Time (UTC).

Returns
A T:System.DateTimeOffset object whose date and time is the current local time and whose offset is the local time zone's offset from Coordinated Universal Time (UTC).

Definition at line 42 of file DateTimeOffset.cs.

◆ Offset

TimeSpan System.DateTimeOffset.Offset
get

Gets the time's offset from Coordinated Universal Time (UTC).

Returns
The difference between the current T:System.DateTimeOffset object's time value and Coordinated Universal Time (UTC).

Definition at line 200 of file DateTimeOffset.cs.

◆ Second

int System.DateTimeOffset.Second
get

Gets the second component of the clock time represented by the current T:System.DateTimeOffset object.

Returns
The second component of the T:System.DateTimeOffset object, expressed as an integer value between 0 and 59.

Definition at line 212 of file DateTimeOffset.cs.

◆ Ticks

long System.DateTimeOffset.Ticks
get

Gets the number of ticks that represents the date and time of the current T:System.DateTimeOffset object in clock time.

Returns
The number of ticks in the T:System.DateTimeOffset object's clock time.

Definition at line 224 of file DateTimeOffset.cs.

◆ TimeOfDay

TimeSpan System.DateTimeOffset.TimeOfDay
get

Gets the time of day for the current T:System.DateTimeOffset object.

Returns
The time interval of the current date that has elapsed since midnight.

Definition at line 248 of file DateTimeOffset.cs.

◆ UtcDateTime

DateTime System.DateTimeOffset.UtcDateTime
get

Gets a T:System.DateTime value that represents the Coordinated Universal Time (UTC) date and time of the current T:System.DateTimeOffset object.

Returns
The Coordinated Universal Time (UTC) date and time of the current T:System.DateTimeOffset object.

Definition at line 78 of file DateTimeOffset.cs.

◆ UtcNow

DateTimeOffset System.DateTimeOffset.UtcNow
staticget

Gets a T:System.DateTimeOffset object whose date and time are set to the current Coordinated Universal Time (UTC) date and time and whose offset is F:System.TimeSpan.Zero.

Returns
An object whose date and time is the current Coordinated Universal Time (UTC) and whose offset is F:System.TimeSpan.Zero.

Definition at line 54 of file DateTimeOffset.cs.

◆ UtcTicks

long System.DateTimeOffset.UtcTicks
get

Gets the number of ticks that represents the date and time of the current T:System.DateTimeOffset object in Coordinated Universal Time (UTC).

Returns
The number of ticks in the T:System.DateTimeOffset object's Coordinated Universal Time (UTC).

Definition at line 236 of file DateTimeOffset.cs.

◆ Year

int System.DateTimeOffset.Year
get

Gets the year component of the date represented by the current T:System.DateTimeOffset object.

Returns
The year component of the current T:System.DateTimeOffset object, expressed as an integer value between 0 and 9999.

Definition at line 260 of file DateTimeOffset.cs.


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