TimeZoneInfo.Utc 屬性

定義

取得代表國際標準時間 (UTC) 時區的 TimeZoneInfo 物件。

public:
 static property TimeZoneInfo ^ Utc { TimeZoneInfo ^ get(); };
public static TimeZoneInfo Utc { get; }
static member Utc : TimeZoneInfo
Public Shared ReadOnly Property Utc As TimeZoneInfo

屬性值

代表國際標準時間 (UTC) 時區的物件。

範例

下列範例會 TimeZoneInfo 擷取代表國際標準時間 (UTC) 的物件,並輸出其顯示名稱、標準時間名稱和日光節約時間名稱。

TimeZoneInfo universalZone = TimeZoneInfo.Utc;
Console.WriteLine("The universal time zone is {0}.", universalZone.DisplayName);
Console.WriteLine("Its standard name is {0}.", universalZone.StandardName);
Console.WriteLine("Its daylight savings name is {0}.", universalZone.DaylightName);
let universalZone = TimeZoneInfo.Utc
printfn $"The universal time zone is {universalZone.DisplayName}."
printfn $"Its standard name is {universalZone.StandardName}."
printfn $"Its daylight savings name is {universalZone.DaylightName}."
Dim universalZone As TimeZoneInfo = TimeZoneInfo.Utc
Console.WriteLine("The universal time zone is {0}.", universalZone.DisplayName)
Console.WriteLine("Its standard name is {0}.", universalZone.StandardName)
Console.WriteLine("Its daylight savings name is {0}.", universalZone.DaylightName)

備註

這是內建物件;此 TimeZoneInfo 物件的相關資訊不會從 Windows 系統上的登錄中擷取,也不會從 Linux 和 macOS 上的 ICU 程式庫 擷取。

重要

您應該一律透過 TimeZoneInfo.Utc 屬性存取國際標準時間 (UTC) 區域,而不是將 UTC 時區指派給 TimeZoneInfo 物件變數。 這可防止 TimeZoneInfo 物件變數因為呼叫 ClearCachedData 方法而失效。

國際標準時間先前稱為 Greenwich Mean Time (GMT) 。

適用於

另請參閱