← Interactive API Explorer
Namespace: System

DateTimeOffset

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

Properties (13)

DateTimeOffset 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).
Value: A 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).
DateTimeOffset 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.
Value: An object whose date and time is the current Coordinated Universal Time (UTC) and whose offset is Zero.
DateTime DateTime
Gets a DateTime value that represents the date and time of the current DateTimeOffset object.
Value: The date and time of the current DateTimeOffset object.
DateTime UtcDateTime
Gets a DateTime value that represents the Coordinated Universal Time (UTC) date and time of the current DateTimeOffset object.
Value: The Coordinated Universal Time (UTC) date and time of the current DateTimeOffset object.
TimeSpan Offset
Gets the time's offset from Coordinated Universal Time (UTC).
Value: The difference between the current DateTimeOffset object's time value and Coordinated Universal Time (UTC).
int Year
Gets the year component of the date represented by the current DateTimeOffset object.
Value: The year component of the current DateTimeOffset object, expressed as an integer value between 0 and 9999.
int Month
Gets the month component of the date represented by the current DateTimeOffset object.
Value: The month component of the current DateTimeOffset object, expressed as an integer between 1 and 12.
int Day
Gets the day of the month represented by the current DateTimeOffset object.
Value: The day component of the current DateTimeOffset object, expressed as a value between 1 and 31.
int Hour
Gets the hour component of the time represented by the current DateTimeOffset object.
Value: The hour component of the current DateTimeOffset object. This property uses a 24-hour clock; the value ranges from 0 to 23.
int Minute
Gets the minute component of the time represented by the current DateTimeOffset object.
Value: The minute component of the current DateTimeOffset object, expressed as an integer between 0 and 59.
int Second
Gets the second component of the clock time represented by the current DateTimeOffset object.
Value: The second component of the DateTimeOffset object, expressed as an integer value between 0 and 59.
int Millisecond
Gets the millisecond component of the time represented by the current DateTimeOffset object.
Value: The millisecond component of the current DateTimeOffset object, expressed as an integer between 0 and 999.
DayOfWeek DayOfWeek
Gets the day of the week represented by the current DateTimeOffset object.
Value: One of the enumeration values that indicates the day of the week of the current DateTimeOffset object.

Methods (10)

DateTimeOffset(DateTime,TimeSpan)Constructor
Initializes a new instance of the DateTimeOffset structure using the specified DateTime value and offset.
ParameterDescription
dateTimeA date and time.
offsetThe time's offset from Coordinated Universal Time (UTC).
DateTimeOffset(Int32,Int32,Int32,Int32,Int32,Int32,TimeSpan)Constructor
Initializes a new instance of the DateTimeOffset structure using the specified year, month, day, hour, minute, second, and offset.
ParameterDescription
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).
DateTimeOffset(Int32,Int32,Int32,Int32,Int32,Int32,Int32,TimeSpan)Constructor
Initializes a new instance of the DateTimeOffset structure using the specified year, month, day, hour, minute, second, millisecond, and offset.
ParameterDescription
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).
DateTimeOffset AddTicks(Int64)
Returns a new DateTimeOffset object that adds a specified number of ticks to the value of this instance.
ParameterDescription
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 DateTimeOffset object and the number of ticks represented by ticks.
DateTimeOffset AddDays(Double)
Returns a new DateTimeOffset object that adds a specified number of whole and fractional days to the value of this instance.
ParameterDescription
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 DateTimeOffset object and the number of days represented by days.
DateTimeOffset AddHours(Double)
Returns a new DateTimeOffset object that adds a specified number of whole and fractional hours to the value of this instance.
ParameterDescription
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 DateTimeOffset object and the number of hours represented by hours.
DateTimeOffset AddMinutes(Double)
Returns a new DateTimeOffset object that adds a specified number of whole and fractional minutes to the value of this instance.
ParameterDescription
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 DateTimeOffset object and the number of minutes represented by minutes.
DateTimeOffset AddSeconds(Double)
Returns a new DateTimeOffset object that adds a specified number of whole and fractional seconds to the value of this instance.
ParameterDescription
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 DateTimeOffset object and the number of seconds represented by seconds.
DateTimeOffset AddMilliseconds(Double)
Returns a new DateTimeOffset object that adds a specified number of milliseconds to the value of this instance.
ParameterDescription
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 DateTimeOffset object and the number of whole milliseconds represented by milliseconds.
DateTimeOffset ToOffset(TimeSpan)
Converts the value of the current DateTimeOffset object to the date and time specified by an offset value.
ParameterDescription
offsetThe offset to convert the DateTimeOffset value to.
Returns: An object that is equal to the original DateTimeOffset object (that is, their ToUniversalTime methods return identical points in time) but whose Offset property is set to offset.