Skip to content

Instantly share code, notes, and snippets.

@aflyen
Created August 23, 2022 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aflyen/dbfa9a3a0658af6e94c2ca6d2fd65667 to your computer and use it in GitHub Desktop.
Save aflyen/dbfa9a3a0658af6e94c2ca6d2fd65667 to your computer and use it in GitHub Desktop.
Format a time from UTC to local timezone in PowerShell
# 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