指定地域(タイムゾーン)の時刻を取得する方法です。
日本(Tokyo)の時刻を取得し、米国(Hawaiian)の時刻に変換します。
TimeZoneInfo型
TImeZoneInfo型の変数を用意します。
日本(Tokyo)と米国(Hawaiian)で2つ変数を用意します。
タイムゾーン情報設定
日本(Tokyo)と米国(Hawaiian)のタイムゾーン情報を変数に設定します。
Tokyo_Time = TimeZoneInfo.FindSystemTimeZoneById(“Tokyo Standard Time”)
Hawaiian_Time = TimeZoneInfo.FindSystemTimeZoneById(“Hawaiian Standard Time”)
※取得したいタイムゾーンIDを赤字に設定
時刻を取得
日本(Tokyo)の現在時刻を取得します。
DateTimeOffset型の変数timeに設定します。
time = New DateTimeOffset(Now(), Tokyo_Time.BaseUtcOffset)
※現在時刻を2018/10/17 23:30:59とします
時刻を変換
取得した日本(Tokyo)時刻を米国(Hawaiian)の時刻に変換し、メッセージボックスに出力します。
TimeZoneInfo.ConvertTime(time, Hawaiian_Time).ToString
タイムゾーンID一覧
UTC-11
Samoa Standard Time
Hawaiian Standard Time
Alaskan Standard Time
Pacific Standard Time (Mexico)
Pacific Standard Time
US Mountain Standard Time
Mountain Standard Time (Mexico)
Mountain Standard Time
Central America Standard Time
Central Standard Time
Central Standard Time (Mexico)
Canada Central Standard Time
SA Pacific Standard Time
Eastern Standard Time
US Eastern Standard Time
Venezuela Standard Time
Paraguay Standard Time
Atlantic Standard Time
Central Brazilian Standard Time
SA Western Standard Time
Pacific SA Standard Time
Newfoundland Standard Time
E. South America Standard Time
Argentina Standard Time
SA Eastern Standard Time
Greenland Standard Time
Montevideo Standard Time
UTC-02
Mid-Atlantic Standard Time
Azores Standard Time
Cape Verde Standard Time
Morocco Standard Time
UTC
GMT Standard Time
Greenwich Standard Time
W. Europe Standard Time
Central Europe Standard Time
Romance Standard Time
Central European Standard Time
W. Central Africa Standard Time
Namibia Standard Time
Jordan Standard Time
GTB Standard Time
Middle East Standard Time
Egypt Standard Time
Syria Standard Time
South Africa Standard Time
FLE Standard Time
Israel Standard Time
E. Europe Standard Time
Arabic Standard Time
Arab Standard Time
Russian Standard Time
E. Africa Standard Time
Iran Standard Time
Arabian Standard Time
Azerbaijan Standard Time
Mauritius Standard Time
Georgian Standard Time
Caucasus Standard Time
Afghanistan Standard Time
Ekaterinburg Standard Time
Pakistan Standard Time
West Asia Standard Time
India Standard Time
Sri Lanka Standard Time
Nepal Standard Time
Central Asia Standard Time
Bangladesh Standard Time
N. Central Asia Standard Time
Myanmar Standard Time
SE Asia Standard Time
North Asia Standard Time
China Standard Time
North Asia East Standard Time
Singapore Standard Time
W. Australia Standard Time
Taipei Standard Time
Ulaanbaatar Standard Time
Tokyo Standard Time
Korea Standard Time
Yakutsk Standard Time
Cen. Australia Standard Time
AUS Central Standard Time
E. Australia Standard Time
AUS Eastern Standard Time
West Pacific Standard Time
Tasmania Standard Time
Vladivostok Standard Time
Central Pacific Standard Time
New Zealand Standard Time
UTC+12
Fiji Standard Time
Kamchatka Standard Time
Tonga Standard Time