Created
August 23, 2022 11:17
-
-
Save aflyen/dbfa9a3a0658af6e94c2ca6d2fd65667 to your computer and use it in GitHub Desktop.
Format a time from UTC to local timezone in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Time in UTC | |
$StartTime = Get-Date "23.08.2022 10:15:00" | |
# Set timezone | |
$TimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("W. Europe Standard Time") | |
# Get time in local timezone | |
$StartTimeLocal = [System.TimeZoneInfo]::ConvertTimeFromUtc($StartTime, $TimeZone) | |
Write-Output "Start: $($StartTime) - Start, local: $($StartTimeLocal) - Timezone: $($TimeZone.DisplayName)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment