TimeZoneInfo.BaseUtcOffset 属性

定义

获取当前时区的标准时间与协调世界时 (UTC) 之间的时差。Gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).

public:
 property TimeSpan BaseUtcOffset { TimeSpan get(); };
public TimeSpan BaseUtcOffset { get; }
member this.BaseUtcOffset : TimeSpan
Public ReadOnly Property BaseUtcOffset As TimeSpan

属性值

TimeSpan

一个对象,它指示当前时区的标准时间与协调世界时 (UTC) 之间的时差。An object that indicates the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).

示例

下面的示例使用 BaseUtcOffset 属性显示本地时间与协调世界时 (UTC) 之间的差值。The following example uses the BaseUtcOffset property to display the difference between the local time and Coordinated Universal Time (UTC).

TimeZoneInfo localZone = TimeZoneInfo.Local;
Console.WriteLine("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");
Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
Console.WriteLine("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"))

注解

此属性返回的时间跨度范围为14小时 (,时区为 BaseUtcOffset 早于协调世界时的14小时 (UTC) ) 到-14 小时后,时区为 14) 小时的时区 (。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). 早于 UTC 的时区具有正偏移量;UTC 后的时区具有负偏移量。Time zones that are ahead of UTC have a positive offset; time zones that are behind UTC have a negative offset.

BaseUtcOffset该值表示为整数分钟数。The BaseUtcOffset value is represented as a whole number of minutes. 它不能包含分钟的小数部分。It cannot include a fractional number of minutes.

备注

由于 BaseUtcOffset 是对象的一个属性,而不是对象的一个属性 TimeZoneInfo TimeZoneInfo.AdjustmentRule ,因此类将 TimeZoneInfo 单个偏移量从 UTC 应用于时区的所有调整。Because BaseUtcOffset is a property of the TimeZoneInfo object rather than the TimeZoneInfo.AdjustmentRule object, the TimeZoneInfo class applies a single offset from UTC to all of a time zone's adjustments. 若要反映修改了其与 UTC 的偏移量的时区,必须使用方法创建一个新时区 CreateCustomTimeZoneTo reflect a time zone that has modified its offset from UTC, you must create a new time zone using the CreateCustomTimeZone method.

BaseUtcOffset 属性 GetUtcOffset 在以下方面与方法不同:The BaseUtcOffset property differs from the GetUtcOffset method in the following ways:

  • BaseUtcOffset属性返回 utc 与时区的标准时间之差; 该 GetUtcOffset 方法返回 utc 与时区在特定时间点的时间之间的差异。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.

  • GetUtcOffset方法反映了时区的任何调整规则的应用; BaseUtcOffset 属性不会。The GetUtcOffset method reflects the application of any adjustment rules to the time zone; the BaseUtcOffset property does not.

适用于

另请参阅