You can use the following basic syntax to convert a datetime variable to UTC time in PowerShell:
$my_UTC_time = ($my_time).ToUniversalTime()
This particular example converts the datetime stored in the $my_time variable to UTC time and saves the result in a variable named $my_UTC_time.
The following example shows how to use this syntax in practice.
Example: How to Convert Date to UTC Time in PowerShell
Suppose that our computer is in the Eastern Standard Timezone (EST).
We can confirm this by using the following syntax in PowerShell:
[System.TimeZoneInfo]::Local.StandardName
The following screenshot shows how to use this syntax in practice:

We can use the following syntax to create a variable named $my_time that gets the current date and time:
$my_time = Get-Date
The following screenshot shows how to use this syntax in practice:

The output displays the current date and time:
- 3/14/2024 10:43:41 AM
We can convert this datetime to UTC time by using the following syntax:
$my_UTC_time = ($my_time).ToUniversalTime()
The following screenshot shows how to use this syntax in practice:

The output displays the datetime in UTC time:
- 3/14/2024 2:43:31 PM
Note that UTC time is four hours ahead of EST time, which is why the $my_UTC_time variable is four hours ahead of the datetime stored in the $my_time variable.
If you would instead like to convert UTC time to EST time, then you could use the following syntax:
[TimeZoneInfo]::ConvertTimeBySystemTimeZoneId($my_UTC_time, 'Eastern Standard Time')
The following screenshot shows how to use this syntax in practice:

Notice that this returns the UTC time in terms of EST time:
- 3/14/2024 10:43:41 AM
Feel free to use similar syntax to convert UTC time to any time zone that you would like.
Related Tutorials
The following tutorials explain how to perform other common tasks in PowerShell:
How to Subtract Time in PowerShell
How to Get Date Without Time in PowerShell
How to Format a DateTime in PowerShell
