How to Display Current Time Zone in PowerShell

John Wachira Feb 15, 2024
How to Display Current Time Zone in PowerShell

This article illustrates how we can get time zone information in PowerShell. We will discuss how we can get our current time zone and a list of all available time zones using the Get-TimeZone cmdlet.

Use the Get-TimeZone Cmdlet to Display Current Time Zone in PowerShell

The Get-TimeZone cmdlet fetches the current time zone and a list of all the available time zones. Below is the syntax for the Get-TimeZone cmdlet:

Get-TimeZone
[[-Name] <String[]>]
[<CommonParameters>]

Let’s look at some examples.

We can get our current time zone using the Get-TimeZone cmdlet as illustrated below:

Get-TimeZone

The command above will return our current time zone.

Display Time Zone Using Get-Timezone

To get all the available time zones, we will run the Get-TimeZone cmdlet as illustrated below:

Get-TimeZone -ListAvailable

We can also use a string from which to fetch the time zone. For example, if we want to get Pacific time zones, we can run the following:

Get-TimeZone -Name "*pacific*"

The command above will get all the time zones that match the pacific wildcard.

Get-Timezone Pacific Timezones

Alternatively, you can run the below command to get your current time zone.

[TimeZoneInfo]::Local

If you want to change the time zone for your system, you can use the Set-TimeZone cmdlet while feeding it with the time zone name or ID as illustrated below:

Set-TimeZone -Id "Pacific Standard Time" -PassThru

In a nutshell, we can use the Get-TimeZone cmdlet to display our current time zone. We can also add the -ListAvailable parameter to display a list of all the available time zones on PowerShell.

Moreover, use the Set-TimeZone cmdlet to change your system’s time zone.

Author: John Wachira
John Wachira avatar John Wachira avatar

John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.

LinkedIn

Related Article - PowerShell Timezone