TimeZone.GetUtcOffset Method

Updated: May 2010

Returns the Coordinated Universal Time (UTC) offset for the specified local time.

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

public abstract function GetUtcOffset(
	time : DateTime
) : TimeSpan


Type: System.DateTime

A date and time value.

Return Value

Type: System.TimeSpan
The Coordinated Universal Time (UTC) offset from Time.

This method returns the offset, or difference, between the time parameter and Coordinated Universal Time (UTC). That is:

time = UTC + offset

The method interprets the time zone of time based on its Kind property. If the value of the Kind property is DateTimeKind.Local or DateTimeKind.Unspecified, the method returns the offset of the local time zone. If the value of the Kind property is DateTimeKind.Utc, the method returns an offset equal to TimeSpan.Zero.

If the local time zone observes daylight saving time, GetUtcOffset applies the current adjustment rule to time when determining the offset of the local time zone. That is, the offset returned by GetUtcOffset reflects whether time falls in the time zone's standard time or its daylight saving time.


   The GetUtcOffset method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the UTC offset of a local time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if Time is a historic date and time value that was subject to a previous adjustment rule.

The GetUtcOffset method corresponds to the TimeZoneInfo.GetUtcOffset method. Whenever possible, use the TimeZoneInfo.GetUtcOffset method.

Because the date and time value represented by Time and this value's offset from UTC are not tightly coupled, a local or unspecified date and time value can return a different offset value when run on different computers or when run on the same computer under different time zones. If this behavior is undesirable, use a DateTimeOffset value instead. The DateTimeOffset data type tightly couples a date and time value with its offset from UTC.

The following example uses the GetUtcOffset method to return the Coordinated Universal Time (UTC) offset for several local times.

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0




May 2010

Added recommendation to use the TimeZoneInfo.GetUtcOffset method.

Information enhancement.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft