PowerTip: Use PowerShell to retrieve the date and time of the given time zone ID


Summary: Use PowerShell to pull out specify TimeZone data from an object.

Hey, Scripting Guy! Question I have data retrieved from an external source that contains different time zone IDs like W. Europe Standard Time, AUS Eastern Standard Time, etc. How can I get the current date time value of it by using PowerShell?

Hey, Scripting Guy! Answer In PowerShell, use [System.TimeZone] and invoke the ConvertTimeBySystemZoneID static method, which returns the date-time value of the given time zone!In PowerShell, use [System.TimeZone] and invoke the ConvertTimeBySystemZoneID static method, which returns the date-time value of the given time zone!

For example, you need to know the current date and time of the AUS Eastern Standard Time.

[System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([DateTime]::Now,"AUS Eastern Standard Time")

Note: This works only if the given time zone is available on your local system. Use [System.TimeZoneInfo]::GetSystemTimeZones() to get the sorted collection of all the time zones about which information is available on the local system.

The Doctor

Comments (1)

  1. PetSerAl says:

    [System.TimeZone] and [System.TimeZoneInfo] are different things.

Skip to main content