DateTimeOffset DateTimeOffset DateTimeOffset DateTimeOffset Struct

Definition

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

public value class DateTimeOffset : IComparable, IComparable<DateTimeOffset>, IEquatable<DateTimeOffset>, IFormattable, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[Serializable]
public struct DateTimeOffset : IComparable, IComparable<DateTimeOffset>, IEquatable<DateTimeOffset>, IFormattable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type DateTimeOffset = struct
    interface IFormattable
    interface ISerializable
    interface IDeserializationCallback
Public Structure DateTimeOffset
Implements IComparable, IComparable(Of DateTimeOffset), IDeserializationCallback, IEquatable(Of DateTimeOffset), IFormattable, ISerializable
Inheritance
DateTimeOffsetDateTimeOffsetDateTimeOffsetDateTimeOffset
Attributes
SerializableAttribute
Implements

Remarks

The DateTimeOffset structure includes a DateTime value, together with an Offset property that defines the difference between the current DateTimeOffset instance's date and time and Coordinated Universal Time (UTC). Because it exactly defines a date and time relative to UTC, the DateTimeOffset structure does not include a Kind member, as the DateTime structure does. It represents dates and times with values whose UTC ranges from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era), to 11:59:59 P.M., December 31, 9999 A.D. (C.E.).

The time component of a DateTimeOffset value is measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the GregorianCalendar calendar. A DateTimeOffset value is always expressed in the context of an explicit or default calendar. Ticks that are attributable to leap seconds are not included in the total number of ticks.

Note

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

Although a DateTimeOffset value includes an offset, it is not a fully time zone-aware data structure. While an offset from UTC is one characteristic of a time zone, it does not unambiguously identify a time zone. Not only do multiple time zones share the same offset from UTC, but the offset of a single time zone changes if it observes daylight saving time. This means that, as soon as a DateTimeOffset value is disassociated from its time zone, it can no longer be unambiguously linked back to its original time zone.

Because DateTimeOffset is a structure, a DateTimeOffset object that has been declared but not otherwise initialized contains the default values for each of its member fields. This means that its DateTime property is set to DateTimeOffset.MinValue and its Offset property is set to TimeSpan.Zero.

You can create a new DateTimeOffset value by calling any of the overloads of its constructor, which are similar to the overloaded constructors for the DateTime structure. You can also create a new DateTimeOffset value by assigning it a DateTime value. This is an implicit conversion; it does not require a casting operator (in C#) or call to a conversion method (in Visual Basic). You can also initialize a DateTimeOffset value from the string representation of a date and time by calling a number of static string parsing methods, which include Parse, ParseExact, TryParse, and TryParseExact.

The members of the DateTimeOffset structure provide functionality in the following areas:

  • Date and time arithmetic.

    You can add or subtract either dates or time intervals from a particular DateTimeOffset value. Arithmetic operations with DateTimeOffset values, unlike those with DateTime values, adjust for differences in time offsets when returning a result. For example, the following code uses DateTime variables to subtract the current local time from the current UTC time. The code then uses DateTimeOffset variables to perform the same operation. The subtraction with DateTime values returns the local time zone's difference from UTC, while the subtraction with DateTimeOffset values returns TimeSpan.Zero.

    using System;
    
    public class DateArithmetic
    {
       public static void Main()
       {
          DateTime date1, date2;
          DateTimeOffset dateOffset1, dateOffset2;
          TimeSpan difference;
          
          // Find difference between Date.Now and Date.UtcNow
          date1 = DateTime.Now;
          date2 = DateTime.UtcNow;
          difference = date1 - date2;
          Console.WriteLine("{0} - {1} = {2}", date1, date2, difference);
          
          // Find difference between Now and UtcNow using DateTimeOffset
          dateOffset1 = DateTimeOffset.Now;
          dateOffset2 = DateTimeOffset.UtcNow;
          difference = dateOffset1 - dateOffset2;
          Console.WriteLine("{0} - {1} = {2}", 
                            dateOffset1, dateOffset2, difference);
          // If run in the Pacific Standard time zone on 4/2/2007, the example
          // displays the following output to the console:
          //    4/2/2007 7:23:57 PM - 4/3/2007 2:23:57 AM = -07:00:00
          //    4/2/2007 7:23:57 PM -07:00 - 4/3/2007 2:23:57 AM +00:00 = 00:00:00                        
       }
    }
    
    Module DateArithmetic
       Public Sub Main()
          Dim date1, date2 As Date
          Dim dateOffset1, dateOffset2 As DateTimeOffset
          Dim difference As TimeSpan
          
          ' Find difference between Date.Now and Date.UtcNow
          date1 = Date.Now
          date2 = Date.UtcNow
          difference = date1 - date2
          Console.WriteLine("{0} - {1} = {2}", date1, date2, difference)
          
          ' Find difference between Now and UtcNow using DateTimeOffset
          dateOffset1 = date.Now
          dateOffset2 = date.UtcNow
          difference = dateOffset1 - dateOffset2
          Console.WriteLine("{0} - {1} = {2}", _
                            dateOffset1, dateOffset2, difference)
          ' If run in the Pacific Standard time zone on 4/2/2007, the example
          ' displays the following output to the console:
          '    4/2/2007 7:23:57 PM - 4/3/2007 2:23:57 AM = -07:00:00
          '    4/2/2007 7:23:57 PM -07:00 - 4/3/2007 2:23:57 AM +00:00 = 00:00:00                        
       End Sub
    End Module
    
  • Type conversion operations.

    You can convert DateTimeOffset values to DateTime values and vice versa.

  • Time manipulation and extraction operations.

    You can extract either the date or the time of a DateTimeOffset value. You can also retrieve the value of a particular DateTimeOffset component, such as its year or its month.

  • Date and time conversion.

    You can convert any DateTimeOffset value to another DateTimeOffset value that represents the same point in time in another time zone. However, a time zone's adjustment rules are applied only in the case of the ToLocalTime method, which converts a DateTimeOffset value to the date and time in the local system zone.

  • Date and time comparison.

    You can determine whether any particular DateTimeOffset value is earlier than, the same as, or later than another DateTimeOffset value. Before the comparison is performed, all values are converted to UTC.

Constructors

DateTimeOffset(DateTime) DateTimeOffset(DateTime) DateTimeOffset(DateTime) DateTimeOffset(DateTime)

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

DateTimeOffset(DateTime, TimeSpan) DateTimeOffset(DateTime, TimeSpan) DateTimeOffset(DateTime, TimeSpan) DateTimeOffset(DateTime, TimeSpan)

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

DateTimeOffset(Int64, TimeSpan) DateTimeOffset(Int64, TimeSpan) DateTimeOffset(Int64, TimeSpan) DateTimeOffset(Int64, TimeSpan)

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

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

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

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

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

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan)

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

Fields

MaxValue MaxValue MaxValue MaxValue

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

MinValue MinValue MinValue MinValue

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

UnixEpoch UnixEpoch UnixEpoch UnixEpoch

Properties

Date Date Date Date

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

DateTime DateTime DateTime DateTime

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

Day Day Day Day

Gets the day of the month represented by the current DateTimeOffset object.

DayOfWeek DayOfWeek DayOfWeek DayOfWeek

Gets the day of the week represented by the current DateTimeOffset object.

DayOfYear DayOfYear DayOfYear DayOfYear

Gets the day of the year represented by the current DateTimeOffset object.

Hour Hour Hour Hour

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

LocalDateTime LocalDateTime LocalDateTime LocalDateTime

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

Millisecond Millisecond Millisecond Millisecond

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

Minute Minute Minute Minute

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

Month Month Month Month

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

Now Now Now Now

Gets a 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).

Offset Offset Offset Offset

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

Second Second Second Second

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

Ticks Ticks Ticks Ticks

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

TimeOfDay TimeOfDay TimeOfDay TimeOfDay

Gets the time of day for the current DateTimeOffset object.

UtcDateTime UtcDateTime UtcDateTime UtcDateTime

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

UtcNow UtcNow UtcNow UtcNow

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

UtcTicks UtcTicks UtcTicks UtcTicks

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

Year Year Year Year

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

Methods

Add(TimeSpan) Add(TimeSpan) Add(TimeSpan) Add(TimeSpan)

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

AddDays(Double) AddDays(Double) AddDays(Double) AddDays(Double)

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

AddHours(Double) AddHours(Double) AddHours(Double) AddHours(Double)

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

AddMilliseconds(Double) AddMilliseconds(Double) AddMilliseconds(Double) AddMilliseconds(Double)

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

AddMinutes(Double) AddMinutes(Double) AddMinutes(Double) AddMinutes(Double)

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

AddMonths(Int32) AddMonths(Int32) AddMonths(Int32) AddMonths(Int32)

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

AddSeconds(Double) AddSeconds(Double) AddSeconds(Double) AddSeconds(Double)

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

AddTicks(Int64) AddTicks(Int64) AddTicks(Int64) AddTicks(Int64)

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

AddYears(Int32) AddYears(Int32) AddYears(Int32) AddYears(Int32)

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

Compare(DateTimeOffset, DateTimeOffset) Compare(DateTimeOffset, DateTimeOffset) Compare(DateTimeOffset, DateTimeOffset) Compare(DateTimeOffset, DateTimeOffset)

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

CompareTo(DateTimeOffset) CompareTo(DateTimeOffset) CompareTo(DateTimeOffset) CompareTo(DateTimeOffset)

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

Equals(DateTimeOffset) Equals(DateTimeOffset) Equals(DateTimeOffset) Equals(DateTimeOffset)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

Equals(DateTimeOffset, DateTimeOffset) Equals(DateTimeOffset, DateTimeOffset) Equals(DateTimeOffset, DateTimeOffset) Equals(DateTimeOffset, DateTimeOffset)

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

EqualsExact(DateTimeOffset) EqualsExact(DateTimeOffset) EqualsExact(DateTimeOffset) EqualsExact(DateTimeOffset)

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

FromFileTime(Int64) FromFileTime(Int64) FromFileTime(Int64) FromFileTime(Int64)

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

FromUnixTimeMilliseconds(Int64) FromUnixTimeMilliseconds(Int64) FromUnixTimeMilliseconds(Int64) FromUnixTimeMilliseconds(Int64)

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

FromUnixTimeSeconds(Int64) FromUnixTimeSeconds(Int64) FromUnixTimeSeconds(Int64) FromUnixTimeSeconds(Int64)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Returns the hash code for the current DateTimeOffset object.

Parse(String) Parse(String) Parse(String) Parse(String)

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

Parse(String, IFormatProvider) Parse(String, IFormatProvider) Parse(String, IFormatProvider) Parse(String, IFormatProvider)

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

Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles) Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles) Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles) Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)
Parse(String, IFormatProvider, DateTimeStyles) Parse(String, IFormatProvider, DateTimeStyles) Parse(String, IFormatProvider, DateTimeStyles) Parse(String, IFormatProvider, DateTimeStyles)

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

ParseExact(String, String[], IFormatProvider, DateTimeStyles) ParseExact(String, String[], IFormatProvider, DateTimeStyles) ParseExact(String, String[], IFormatProvider, DateTimeStyles) ParseExact(String, String[], IFormatProvider, DateTimeStyles)

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

ParseExact(String, String, IFormatProvider, DateTimeStyles) ParseExact(String, String, IFormatProvider, DateTimeStyles) ParseExact(String, String, IFormatProvider, DateTimeStyles) ParseExact(String, String, IFormatProvider, DateTimeStyles)

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

ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles) ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles) ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles) ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

Converts a character span that represents a date and time to its DateTimeOffset equivalent using the specified format, culture-specific format information, and style. The format of the date and time representation must match the specified format exactly.

ParseExact(String, String, IFormatProvider) ParseExact(String, String, IFormatProvider) ParseExact(String, String, IFormatProvider) ParseExact(String, String, IFormatProvider)

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

ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles) ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles) ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles) ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles)

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

Subtract(DateTimeOffset) Subtract(DateTimeOffset) Subtract(DateTimeOffset) Subtract(DateTimeOffset)

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

Subtract(TimeSpan) Subtract(TimeSpan) Subtract(TimeSpan) Subtract(TimeSpan)

Subtracts a specified time interval from the current DateTimeOffset object.

ToFileTime() ToFileTime() ToFileTime() ToFileTime()

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

ToLocalTime() ToLocalTime() ToLocalTime() ToLocalTime()

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

ToOffset(TimeSpan) ToOffset(TimeSpan) ToOffset(TimeSpan) ToOffset(TimeSpan)

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

ToString() ToString() ToString() ToString()

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

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

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

ToString(String) ToString(String) ToString(String) ToString(String)

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

ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider)

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

ToUniversalTime() ToUniversalTime() ToUniversalTime() ToUniversalTime()

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

ToUnixTimeMilliseconds() ToUnixTimeMilliseconds() ToUnixTimeMilliseconds() ToUnixTimeMilliseconds()

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

ToUnixTimeSeconds() ToUnixTimeSeconds() ToUnixTimeSeconds() ToUnixTimeSeconds()

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

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)
TryParse(String, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParse(String, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParse(String, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParse(String, IFormatProvider, DateTimeStyles, DateTimeOffset)

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

TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset)
TryParse(String, DateTimeOffset) TryParse(String, DateTimeOffset) TryParse(String, DateTimeOffset) TryParse(String, DateTimeOffset)

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

TryParse(ReadOnlySpan<Char>, DateTimeOffset) TryParse(ReadOnlySpan<Char>, DateTimeOffset) TryParse(ReadOnlySpan<Char>, DateTimeOffset) TryParse(ReadOnlySpan<Char>, DateTimeOffset)
TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTimeOffset)

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

TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, DateTimeOffset)

Converts the representation of a date and time in a character span to its DateTimeOffset equivalent using the specified format, culture-specific format information, and style. The format of the date and time representation must match the specied format exactly.

TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, DateTimeOffset)
TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTimeOffset) TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTimeOffset)

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

Operators

Addition(DateTimeOffset, TimeSpan) Addition(DateTimeOffset, TimeSpan) Addition(DateTimeOffset, TimeSpan) Addition(DateTimeOffset, TimeSpan)

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

Equality(DateTimeOffset, DateTimeOffset) Equality(DateTimeOffset, DateTimeOffset) Equality(DateTimeOffset, DateTimeOffset) Equality(DateTimeOffset, DateTimeOffset)

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

GreaterThan(DateTimeOffset, DateTimeOffset) GreaterThan(DateTimeOffset, DateTimeOffset) GreaterThan(DateTimeOffset, DateTimeOffset) GreaterThan(DateTimeOffset, DateTimeOffset)

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

GreaterThanOrEqual(DateTimeOffset, DateTimeOffset) GreaterThanOrEqual(DateTimeOffset, DateTimeOffset) GreaterThanOrEqual(DateTimeOffset, DateTimeOffset) GreaterThanOrEqual(DateTimeOffset, DateTimeOffset)

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

Implicit(DateTime to DateTimeOffset) Implicit(DateTime to DateTimeOffset) Implicit(DateTime to DateTimeOffset) Implicit(DateTime to DateTimeOffset)

Defines an implicit conversion of a DateTime object to a DateTimeOffset object.

Inequality(DateTimeOffset, DateTimeOffset) Inequality(DateTimeOffset, DateTimeOffset) Inequality(DateTimeOffset, DateTimeOffset) Inequality(DateTimeOffset, DateTimeOffset)

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

LessThan(DateTimeOffset, DateTimeOffset) LessThan(DateTimeOffset, DateTimeOffset) LessThan(DateTimeOffset, DateTimeOffset) LessThan(DateTimeOffset, DateTimeOffset)

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

LessThanOrEqual(DateTimeOffset, DateTimeOffset) LessThanOrEqual(DateTimeOffset, DateTimeOffset) LessThanOrEqual(DateTimeOffset, DateTimeOffset) LessThanOrEqual(DateTimeOffset, DateTimeOffset)

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

Subtraction(DateTimeOffset, DateTimeOffset) Subtraction(DateTimeOffset, DateTimeOffset) Subtraction(DateTimeOffset, DateTimeOffset) Subtraction(DateTimeOffset, DateTimeOffset)

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

Subtraction(DateTimeOffset, TimeSpan) Subtraction(DateTimeOffset, TimeSpan) Subtraction(DateTimeOffset, TimeSpan) Subtraction(DateTimeOffset, TimeSpan)

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

Explicit Interface Implementations

IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object)

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

IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object)

Runs when the deserialization of an object has been completed.

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo object with the data required to serialize the current DateTimeOffset object.

Applies to

See Also