Azure

Change timezone for an Azure WebApp

When testing output caching for this blog, I added the timestamp for when the page were generated to the bottom of the markup, like this.

<!-- @DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") -->

Even though the App Service was placed in the location «Norway East», the timestamp was UTC and not my local time zone.

So, how can the default time zone be changed? Simply add an App Setting with the name WEBSITE_TIME_ZONE, and set its value to the time zone you want.

The possible values can be found in the registry (use regedit.exe) and navigate to:

\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\

A list of time zones from the Windows registry

I set the value to Central European Standard Time, like this:

Azure AppSettings with timezone settings

Be aware that changing the app settings will trigger a restart of your WebApp.

That's it!