{"id":79845,"date":"2016-09-16T11:59:43","date_gmt":"2016-09-16T18:59:43","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=79845"},"modified":"2019-02-18T09:10:27","modified_gmt":"2019-02-18T16:10:27","slug":"powertip-use-powershell-to-retrieve-the-date-and-time-of-the-given-time-zone-id","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-use-powershell-to-retrieve-the-date-and-time-of-the-given-time-zone-id\/","title":{"rendered":"PowerTip: Use PowerShell to retrieve the date and time of the given time zone ID"},"content":{"rendered":"<p><strong>Summary<\/strong>: Use PowerShell to pull out specify TimeZone data from an object.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"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?<\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/> In PowerShell, use <strong>[System.TimeZone]<\/strong> and invoke the <strong>ConvertTimeBySystemZoneID<\/strong> static method, which returns the date-time value of the given time zone!In PowerShell, use <strong>[System.TimeZone]<\/strong> and invoke the <strong>ConvertTimeBySystemZoneID<\/strong> static method, which returns the date-time value of the given time zone!<\/p>\n<p style=\"padding-left: 30px\">For example, you need to know the current date and time of the <strong>AUS Eastern Standard Time<\/strong>.<\/p>\n<p style=\"padding-left: 60px\"><code>[System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([DateTime]::Now,\"AUS Eastern Standard Time\")<\/code><\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong>:\u00a0This works only if the given time zone is available on your local system. Use <strong>[System.TimeZoneInfo]::GetSystemTimeZones() <\/strong>to get the sorted collection of all the time zones about which information is available on the local system<strong>.<\/strong><\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\"The Doctor\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[568,639,685,641],"tags":[696,56,356,45],"class_list":["post-79845","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-powertip","category-scripting-techniques","category-windows-powershell","tag-chendrayan-venkatesan","tag-guest-blogger","tag-powertip","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/79845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=79845"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/79845\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=79845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=79845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=79845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}