Finding Out UTC Time

by Mar 21, 2016

When you work in a global environment, it sometimes becomes necessary to translate the local time to UTC (Universal Time). The conversion is done by ToUniversalTime(). This method is part of any DateTime object. In this example, your local time is translated to UTC:

$date = Get-Date
$date.ToUniversalTime()

Likewise, you can take a UTC value and convert it back to your local time:

$date = Get-Date -Date '2016-03-12 18:33:12'
$date.ToLocalTime()

Or you can find out the time difference between your time zone and UTC:

(Get-Date) - (Get-Date).ToUniversalTime()

Twitter This Tip! ReTweet this Tip!