PowerTip: Convert from UTC to my local time zone
Summary: Cloud and Datacenter Management MVP, Thomas Rayner, shows how write a function to convert from UTC to your local time zone.
I have a time that I’d like to convert from UTC to my local time zone. How can I do this?
You can write your own function to do this, and use the [System.TimeZoneInfo] .NET class and associated methods to make this conversion easily. Here is an example:
function Convert-UTCtoLocal
{param([parameter(Mandatory=$true)][String] $UTCTime)
$strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName$TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)$LocalTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ)}
0 comments