Obviously, you can ask your computer for the current time zone like this:

 
PS> Get-TimeZone


Id                         : W. Europe Standard Time
DisplayName                : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
StandardName               : W. Europe Standard Time
DaylightName               : W. Europe Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True   
 

Whether or not this information is correct, though, depends on your actual configuration. When you travel with your notebook to a different place, this won’t necessarily update your time zone.

Another way of finding out the current time zone is to call a public web service. Based on your current internet connection, it returns the time zone based on where you currently are:

 
PS> Invoke-RestMethod -Uri 'http://worldtimeapi.org/api/ip'


abbreviation : CET
client_ip    : 84.183.236.178
datetime     : 2021-01-04T13:31:57.398092+01:00
day_of_week  : 1
day_of_year  : 4
dst          : False
dst_from     : 
dst_offset   : 0
dst_until    : 
raw_offset   : 3600
timezone     : Europe/Berlin
unixtime     : 1609763517
utc_datetime : 2021-01-04T12:31:57.398092+00:00
utc_offset   : +01:00
week_number  : 1   
 




Twitter This Tip! ReTweet this Tip!

Anonymous