Sdílet prostřednictvím


TimeZoneInfo.BaseUtcOffset Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).

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

Syntax

'Declaration
Public ReadOnly Property BaseUtcOffset As TimeSpan
public TimeSpan BaseUtcOffset { get; }

Property Value

Type: System.TimeSpan
A TimeSpan object that indicates the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).

Remarks

The time span returned by the BaseUtcOffset property can range from 14 hours (for a time zone that is 14 hours ahead of Coordinated Universal Time (UTC)) to -14 hours (for a time zone that is 14 hours behind UTC). Time zones that are ahead of UTC have a positive offset; time zones that are behind UTC have a negative offset.

The BaseUtcOffset value is represented as a whole number of minutes. It cannot include a fractional number of minutes.

The BaseUtcOffset property differs from the GetUtcOffset method in the following ways:

  • The BaseUtcOffset property returns the difference between UTC and the time zone's standard time; the GetUtcOffset method returns the difference between UTC and the time zone's time at a particular point in time.

  • The GetUtcOffset method reflects the application of any adjustment rules to the time zone; the BaseUtcOffset property does not.

Version Notes

XNA Framework

 When this property is used in the XNA Framework, it throws a NotSupportedException exception.

Examples

The following example uses the BaseUtcOffset property to display the difference between the local time and Coordinated Universal Time (UTC).

Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
outputBlock.Text &= String.Format("The {0} time zone is {1}:{2} {3} than Coordinated Universal Time.", _
                  localZone.StandardName, _
                  Math.Abs(localZone.BaseUtcOffset.Hours), _
                  Math.Abs(localZone.BaseUtcOffset.Minutes), _
                  IIf(localZone.BaseUtcOffset >= TimeSpan.Zero, "later", "earlier")) + vbCrLf
TimeZoneInfo localZone = TimeZoneInfo.Local;
outputBlock.Text += String.Format("The {0} time zone is {1}:{2} {3} than Coordinated Universal Time.",
                  localZone.DisplayName,
                  Math.Abs(localZone.BaseUtcOffset.Hours),
                  Math.Abs(localZone.BaseUtcOffset.Minutes),
                  (localZone.BaseUtcOffset >= TimeSpan.Zero) ? "later" : "earlier") + "\n";

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.