struct DateTimeOffset
Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Universal Time (UTC).
public DateTimeOffset( DateTime dateTime )
Initializes a new instance of the structure using the specified value.
dateTimeA date and time.
public DateTimeOffset( DateTime dateTime, TimeSpan offset )
Initializes a new instance of the structure using the specified value and offset.
dateTimeA date and time.offsetThe time's offset from Coordinated Universal Time (UTC).
public 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 structure using the specified year, month, day, hour, minute, second, millisecond, and offset of a specified calendar.
yearThe year.monthThe month (1 through 12).dayThe day (1 through the number of days in ).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 , , and .offsetThe time's offset from Coordinated Universal Time (UTC).
public DateTimeOffset( int year, int month, int day, int hour, int minute, int second, int millisecond, TimeSpan offset )
Initializes a new instance of the structure using the specified year, month, day, hour, minute, second, millisecond, and offset.
yearThe year (1 through 9999).monthThe month (1 through 12).dayThe day (1 through the number of days in ).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).
public DateTimeOffset( int year, int month, int day, int hour, int minute, int second, TimeSpan offset )
Initializes a new instance of the structure using the specified year, month, day, hour, minute, second, and offset.
yearThe year (1 through 9999).monthThe month (1 through 12).dayThe day (1 through the number of days in ).hourThe hours (0 through 23).minuteThe minutes (0 through 59).secondThe seconds (0 through 59).offsetThe time's offset from Coordinated Universal Time (UTC).
public DateTimeOffset( long ticks, TimeSpan offset )
Initializes a new instance of the structure using the specified number of ticks and offset.
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).
public DateTimeOffset Add( TimeSpan timeSpan )
Returns a new object that adds a specified time interval to the value of this instance.
timeSpanA 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 object and the time interval represented by .
public DateTimeOffset AddDays( double days )
Returns a new object that adds a specified number of whole and fractional days to the value of this instance.
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 object and the number of days represented by .
public DateTimeOffset AddHours( double hours )
Returns a new object that adds a specified number of whole and fractional hours to the value of this instance.
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 object and the number of hours represented by .
public DateTimeOffset AddMilliseconds( double milliseconds )
Returns a new object that adds a specified number of milliseconds to the value of this instance.
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 object and the number of whole milliseconds represented by .
public DateTimeOffset AddMinutes( double minutes )
Returns a new object that adds a specified number of whole and fractional minutes to the value of this instance.
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 object and the number of minutes represented by .
public DateTimeOffset AddMonths( int months )
Returns a new object that adds a specified number of months to the value of this instance.
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 object and the number of months represented by .
public DateTimeOffset AddSeconds( double seconds )
Returns a new object that adds a specified number of whole and fractional seconds to the value of this instance.
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 object and the number of seconds represented by .
public DateTimeOffset AddTicks( long ticks )
Returns a new object that adds a specified number of ticks to the value of this instance.
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 object and the number of ticks represented by .
public DateTimeOffset AddYears( int years )
Returns a new object that adds a specified number of years to the value of this instance.
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 object and the number of years represented by .
public static int Compare( DateTimeOffset first, DateTimeOffset second )
Compares two objects and indicates whether the first is earlier than the second, equal to the second, or later than the second.
firstThe first object to compare.secondThe second object to compare.- Returns A signed integer that indicates whether the value of the parameter is earlier than, later than, or the same time as the value of the parameter, as the following table shows. Return value Meaning Less than zero is earlier than . Zero is equal to . Greater than zero is later than .
public int CompareTo( DateTimeOffset other )
Compares the current object to a specified object and indicates whether the current object is earlier than, the same as, or later than the second object.
otherAn object to compare with the current object.- Returns A signed integer that indicates the relationship between the current object and , as the following table shows. Return Value Description Less than zero The current object is earlier than . Zero The current object is the same as . Greater than zero. The current object is later than .
public DateTime Date { get; }
Gets a value that represents the date component of the current object.
- Returns A value that represents the date component of the current object.
public DateTime DateTime { get; }
Gets a value that represents the date and time of the current object.
- Returns The date and time of the current object.
public int Day { get; }
Gets the day of the month represented by the current object.
- Returns The day component of the current object, expressed as a value between 1 and 31.
public DayOfWeek DayOfWeek { get; }
Gets the day of the week represented by the current object.
- Returns One of the enumeration values that indicates the day of the week of the current object.
public int DayOfYear { get; }
Gets the day of the year represented by the current object.
- Returns The day of the year of the current object, expressed as a value between 1 and 366.
public bool Equals( DateTimeOffset other )
Determines whether the current object represents the same point in time as a specified object.
otherAn object to compare to the current object.- Returns if both objects have the same value; otherwise, .
public static bool Equals( DateTimeOffset first, DateTimeOffset second )
Determines whether two specified objects represent the same point in time.
firstThe first object to compare.secondThe second object to compare.- Returns if the two objects have the same value; otherwise, .
public bool Equals( object obj )
Determines whether a object represents the same point in time as a specified object.
objThe object to compare to the current object.- Returns if the parameter is a object and represents the same point in time as the current object; otherwise, .
public bool EqualsExact( DateTimeOffset other )
Determines whether the current object represents the same time and has the same offset as a specified object.
otherThe object to compare to the current object.- Returns if the current object and have the same date and time value and the same value; otherwise, .
public static DateTimeOffset FromFileTime( long fileTime )
Converts the specified Windows file time to an equivalent local time.
fileTimeA Windows file time, expressed in ticks.- Returns An object that represents the date and time of with the offset set to the local time offset.
public 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 value.
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.
public 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 value.
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.
public int Hour { get; }
Gets the hour component of the time represented by the current object.
- Returns The hour component of the current object. This property uses a 24-hour clock; the value ranges from 0 to 23.
public DateTime LocalDateTime { get; }
Gets a value that represents the local date and time of the current object.
- Returns The local date and time of the current object.
public static DateTimeOffset MaxValue
Represents the greatest possible value of . This field is read-only.
public int Millisecond { get; }
Gets the millisecond component of the time represented by the current object.
- Returns The millisecond component of the current object, expressed as an integer between 0 and 999.
public int Minute { get; }
Gets the minute component of the time represented by the current object.
- Returns The minute component of the current object, expressed as an integer between 0 and 59.
public static DateTimeOffset MinValue
Represents the earliest possible value. This field is read-only.
public int Month { get; }
Gets the month component of the date represented by the current object.
- Returns The month component of the current object, expressed as an integer between 1 and 12.
public static DateTimeOffset Now { get; }
Gets a 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 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).
public TimeSpan Offset { get; }
Gets the time's offset from Coordinated Universal Time (UTC).
- Returns The difference between the current object's time value and Coordinated Universal Time (UTC).
public static DateTimeOffset op_Addition( DateTimeOffset dateTimeOffset, TimeSpan timeSpan )
Adds a specified time interval to a object that has a specified date and time, and yields a object that has new a date and time.
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 and .
public static bool op_Equality( DateTimeOffset left, DateTimeOffset right )
Determines whether two specified objects represent the same point in time.
leftThe first object to compare.rightThe second object to compare.- Returns if both objects have the same value; otherwise, .
public static bool op_GreaterThan( DateTimeOffset left, DateTimeOffset right )
Determines whether one specified object is greater than (or later than) a second specified object.
leftThe first object to compare.rightThe second object to compare.- Returns if the value of is later than the value of ; otherwise, .
public static bool op_GreaterThanOrEqual( DateTimeOffset left, DateTimeOffset right )
Determines whether one specified object is greater than or equal to a second specified object.
leftThe first object to compare.rightThe second object to compare.- Returns if the value of is the same as or later than the value of ; otherwise, .
public static bool op_Inequality( DateTimeOffset left, DateTimeOffset right )
Determines whether two specified objects refer to different points in time.
leftThe first object to compare.rightThe second object to compare.- Returns if and do not have the same value; otherwise, .
public static bool op_LessThan( DateTimeOffset left, DateTimeOffset right )
Determines whether one specified object is less than a second specified object.
leftThe first object to compare.rightThe second object to compare.- Returns if the value of is earlier than the value of ; otherwise, .
public static bool op_LessThanOrEqual( DateTimeOffset left, DateTimeOffset right )
Determines whether one specified object is less than a second specified object.
leftThe first object to compare.rightThe second object to compare.- Returns if the value of is earlier than the value of ; otherwise, .
public static TimeSpan op_Subtraction( DateTimeOffset left, DateTimeOffset right )
Subtracts one object from another and yields a time interval.
leftThe minuend.rightThe subtrahend.- Returns An object that represents the difference between and .
public static DateTimeOffset op_Subtraction( DateTimeOffset dateTimeOffset, TimeSpan timeSpan )
Subtracts a specified time interval from a specified date and time, and yields a new date and time.
dateTimeOffsetThe date and time object to subtract from.timeSpanThe time interval to subtract.- Returns An object that is equal to the value of minus .
public static DateTimeOffset Parse( string input )
Converts the specified string representation of a date, time, and offset to its equivalent.
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 .
public static DateTimeOffset Parse( string input, IFormatProvider formatProvider )
Converts the specified string representation of a date and time to its equivalent using the specified culture-specific format information.
inputA string that contains a date and time to convert.formatProviderAn object that provides culture-specific format information about .- Returns An object that is equivalent to the date and time that is contained in , as specified by .
public static DateTimeOffset Parse( string input, IFormatProvider formatProvider, DateTimeStyles styles )
Converts the specified string representation of a date and time to its equivalent using the specified culture-specific format information and formatting style.
inputA string that contains a date and time to convert.formatProviderAn object that provides culture-specific format information about .stylesA bitwise combination of enumeration values that indicates the permitted format of . A typical value to specify is .- Returns An object that is equivalent to the date and time that is contained in as specified by and .
public static DateTimeOffset ParseExact( string input, string format, IFormatProvider formatProvider )
Converts the specified string representation of a date and time to its equivalent using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly.
inputA string that contains a date and time to convert.formatA format specifier that defines the expected format of .formatProviderAn object that supplies culture-specific formatting information about .- Returns An object that is equivalent to the date and time that is contained in as specified by and .
public static DateTimeOffset ParseExact( string input, string format, IFormatProvider formatProvider, DateTimeStyles styles )
Converts the specified string representation of a date and time to its equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly.
inputA string that contains a date and time to convert.formatA format specifier that defines the expected format of .formatProviderAn object that supplies culture-specific formatting information about .stylesA bitwise combination of enumeration values that indicates the permitted format of .- Returns An object that is equivalent to the date and time that is contained in the parameter, as specified by the , , and parameters.
public static DateTimeOffset ParseExact( string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles )
Converts the specified string representation of a date and time to its 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.
inputA string that contains a date and time to convert.formatsAn array of format specifiers that define the expected formats of .formatProviderAn object that supplies culture-specific formatting information about .stylesA bitwise combination of enumeration values that indicates the permitted format of .- Returns An object that is equivalent to the date and time that is contained in the parameter, as specified by the , , and parameters.
public int Second { get; }
Gets the second component of the clock time represented by the current object.
- Returns The second component of the object, expressed as an integer value between 0 and 59.
public TimeSpan Subtract( DateTimeOffset value )
Subtracts a value that represents a specific date and time from the current object.
valueAn object that represents the value to subtract.- Returns An object that specifies the interval between the two objects.
public DateTimeOffset Subtract( TimeSpan value )
Subtracts a specified time interval from the current object.
valueThe time interval to subtract.- Returns An object that is equal to the date and time represented by the current object, minus the time interval represented by .
public long Ticks { get; }
Gets the number of ticks that represents the date and time of the current object in clock time.
- Returns The number of ticks in the object's clock time.
public TimeSpan TimeOfDay { get; }
Gets the time of day for the current object.
- Returns The time interval of the current date that has elapsed since midnight.
public DateTimeOffset ToOffset( TimeSpan offset )
Converts the value of the current object to the date and time specified by an offset value.
offsetThe offset to convert the value to.- Returns An object that is equal to the original object (that is, their methods return identical points in time) but whose property is set to .
public string ToString( IFormatProvider formatProvider )
Converts the value of the current object to its equivalent string representation using the specified culture-specific formatting information.
formatProviderAn object that supplies culture-specific formatting information.- Returns A string representation of the value of the current object, as specified by .
public string ToString( string format )
Converts the value of the current object to its equivalent string representation using the specified format.
formatA format string.- Returns A string representation of the value of the current object, as specified by .
public string ToString( string format, IFormatProvider formatProvider )
Converts the value of the current object to its equivalent string representation using the specified format and culture-specific format information.
formatA format string.formatProviderAn object that supplies culture-specific formatting information.- Returns A string representation of the value of the current object, as specified by and .
public static bool TryParse( string input, ref DateTimeOffset result )
Tries to converts a specified string representation of a date and time to its equivalent, and returns a value that indicates whether the conversion succeeded.
inputA string that contains a date and time to convert.resultWhen the method returns, contains the equivalent to the date and time of , if the conversion succeeded, or , if the conversion failed. The conversion fails if the parameter is or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.- Returns if the parameter is successfully converted; otherwise, .
public static bool TryParse( string input, IFormatProvider formatProvider, DateTimeStyles styles, ref DateTimeOffset result )
Tries to convert a specified string representation of a date and time to its equivalent, and returns a value that indicates whether the conversion succeeded.
inputA string that contains a date and time to convert.formatProviderAn object that provides culture-specific formatting information about .stylesA bitwise combination of enumeration values that indicates the permitted format of .resultWhen the method returns, contains the value equivalent to the date and time of , if the conversion succeeded, or , if the conversion failed. The conversion fails if the parameter is or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.- Returns if the parameter is successfully converted; otherwise, .
public static bool TryParseExact( string input, string format, IFormatProvider formatProvider, DateTimeStyles styles, ref DateTimeOffset result )
Converts the specified string representation of a date and time to its equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly.
inputA string that contains a date and time to convert.formatA format specifier that defines the required format of .formatProviderAn object that supplies culture-specific formatting information about .stylesA bitwise combination of enumeration values that indicates the permitted format of input. A typical value to specify is .resultWhen the method returns, contains the equivalent to the date and time of , if the conversion succeeded, or , if the conversion failed. The conversion fails if the parameter is , or does not contain a valid string representation of a date and time in the expected format defined by and provider. This parameter is passed uninitialized.- Returns if the parameter is successfully converted; otherwise, .
public static bool TryParseExact( string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles, ref DateTimeOffset result )
Converts the specified string representation of a date and time to its equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match one of the specified formats exactly.
inputA string that contains a date and time to convert.formatsAn array that defines the expected formats of .formatProviderAn object that supplies culture-specific formatting information about .stylesA bitwise combination of enumeration values that indicates the permitted format of input. A typical value to specify is .resultWhen the method returns, contains the equivalent to the date and time of , if the conversion succeeded, or , if the conversion failed. The conversion fails if the 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 , or if is . This parameter is passed uninitialized.- Returns if the parameter is successfully converted; otherwise, .
public static DateTimeOffset UnixEpoch
No summary.
public DateTime UtcDateTime { get; }
Gets a value that represents the Coordinated Universal Time (UTC) date and time of the current object.
- Returns The Coordinated Universal Time (UTC) date and time of the current object.
public static DateTimeOffset UtcNow { get; }
Gets a object whose date and time are set to the current Coordinated Universal Time (UTC) date and time and whose offset is .
- Returns An object whose date and time is the current Coordinated Universal Time (UTC) and whose offset is .
public long UtcTicks { get; }
Gets the number of ticks that represents the date and time of the current object in Coordinated Universal Time (UTC).
- Returns The number of ticks in the object's Coordinated Universal Time (UTC).
public int Year { get; }
Gets the year component of the date represented by the current object.
- Returns The year component of the current object, expressed as an integer value between 0 and 9999.
public DateTimeOffset( int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, Calendar calendar, TimeSpan offset )
😔 No documentation found.
public DateTimeOffset( int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, TimeSpan offset )
😔 No documentation found.
public int Microsecond { get; }
😔 No documentation found.
public int Nanosecond { get; }
😔 No documentation found.
public int TotalOffsetMinutes { get; }
😔 No documentation found.
public DateTimeOffset( DateOnly date, TimeOnly time, TimeSpan offset )
😔 No documentation found.
public DateTimeOffset AddMicroseconds( double microseconds )
😔 No documentation found.
public Type GetType( )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.
public static bool TryParse( ReadOnlySpan<char> s, IFormatProvider provider, ref DateTimeOffset result )
😔 No documentation found.
public static DateTimeOffset Parse( ReadOnlySpan<char> s, IFormatProvider provider )
😔 No documentation found.
public static bool TryParse( ReadOnlySpan<char> input, ref DateTimeOffset result )
😔 No documentation found.
public static bool TryParse( string s, IFormatProvider provider, ref DateTimeOffset result )
😔 No documentation found.
public static DateTimeOffset Parse( ReadOnlySpan<char> input, IFormatProvider formatProvider = null, DateTimeStyles styles = None )
😔 No documentation found.
public static DateTimeOffset ParseExact( ReadOnlySpan<char> input, ReadOnlySpan<char> format, IFormatProvider formatProvider, DateTimeStyles styles = None )
😔 No documentation found.
public static DateTimeOffset ParseExact( ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles = None )
😔 No documentation found.
public long ToFileTime( )
😔 No documentation found.
public long ToUnixTimeSeconds( )
😔 No documentation found.
public long ToUnixTimeMilliseconds( )
😔 No documentation found.
public DateTimeOffset ToLocalTime( )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public bool TryFormat( Span<char> destination, ref int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider formatProvider = null )
😔 No documentation found.
public static DateTimeOffset op_Implicit( DateTime dateTime )
😔 No documentation found.
public static bool TryParseExact( ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles, ref DateTimeOffset result )
😔 No documentation found.
public bool TryFormat( Span<byte> utf8Destination, ref int bytesWritten, ReadOnlySpan<char> format = null, IFormatProvider formatProvider = null )
😔 No documentation found.
public static bool TryParseExact( ReadOnlySpan<char> input, ReadOnlySpan<char> format, IFormatProvider formatProvider, DateTimeStyles styles, ref DateTimeOffset result )
😔 No documentation found.
public DateTimeOffset ToUniversalTime( )
😔 No documentation found.
public void Deconstruct( ref DateOnly date, ref TimeOnly time, ref TimeSpan offset )
😔 No documentation found.
public static bool TryParse( ReadOnlySpan<char> input, IFormatProvider formatProvider, DateTimeStyles styles, ref DateTimeOffset result )
😔 No documentation found.