DateTimeOffset.ToOffset Method (TimeSpan)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

member ToOffset : 
        offset:TimeSpan -> DateTimeOffset


Type: System.TimeSpan

The offset to convert the DateTimeOffset value to.

Return Value

Type: System.DateTimeOffset

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.

Exception Condition

The resulting DateTimeOffset object has a DateTime value earlier than MinValue.


The resulting DateTimeOffset object has a DateTime value later than MaxValue.


offset is less than -14 hours.


offset is greater than 14 hours.

The ToOffset method is an alternative to calling the TimeZoneInfo.ConvertTime(DateTimeOffset, TimeZoneInfo) method. It can be useful for performing simple conversions from one time zone to another when the time zones' offsets from Coordinated Universal Time (UTC) are known. However, because neither the original DateTimeOffset object nor the new DateTimeOffset object returned by the method call are unambiguously related to a particular time zone, the method does not apply any time zone adjustment rules in the conversion.

The following example illustrates how to use the ToOffset method to convert a DateTimeOffset object to a DateTimeOffset object with a different offset.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top