Summary: Use PowerShell to pull out specify TimeZone data from an object.
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?
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.
0 comments