SQL Server with Mr. Denny

May 6 2019   4:00PM GMT

Changing the Time Zone of Azure VMs

Denny Cherry Denny Cherry Profile: Denny Cherry

Tags:

When you create a VM in Azure it’s always set to the UTC timezone. There are some times when that doesn’t work and it needs to be set for a specific time zone. In a perfect world, the apps could be fixed so that they could deal with the fact that the servers are now in UTC instead of the local timezone. But this isn’t always possible, and the server’s time zone needs to be changed.

The “normal” process to change the timezone for a Windows server doesn’t work as expected. You can change the time zone by right-clicking on the clock and selecting “Adjust Date and Time”. If you change the time zone here, it doesn’t actually do anything (at least it didn’t when I did it).  It may also change for a short period of time and then revert back to UTC.

If you use PowerShell to change the timezone the change will stick, even if the VM is deallocated and reallocated.

First, we need to see what the options are for changing the timezone.  We can see that by running the Get-TimeZone cmdlet.
Get-TimeZone -ListAvailable
If a list of every time zone possible isn’t helpful (and it probably isn’t) you can filter the list down as you probably know the name of the time zone you’re looking for.  My specific client needed a server created in the Pacific Time Zone, So I filtered it down by the word Pacific.
Get-TimeZone -ListAvailable | where ({$_.Id -like "Pacific*"})
Second, we then use the cmdlet Set-TimeZone to change the time zone of the VM.  You’ll want to put the ID from the Get-TimeZone cmdlet into the ID parameter of the Set-TimeZone cmdlet.

Set-TimeZone -Id "Pacific Standard Time"

Denny

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: