This documentation is archived and is not being maintained.

DateTimeOffset.ToOffset Method

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.


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.

.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.