Change the Server Time of an Azure App Service

Alberto De Natale
2 min readJun 21, 2019

--

When hosting a web application on a classic server or a virtual machine, changing the server time is relatively straightforward.

When working on the cloud, it becomes easier having to deal with timezones as the location of your server can often be distant from where the application is running.

DateTime.Now vs DateTime.UtcNow

UTC stands for “Coordinated Universal Time”.

The concept is well explained in this answer:

When using DateTime.Now to display a DateTime consider that server DateTime will be shown to them.

WEBSITE_TIME_ZONE

AppServices run by default in UTC time. If you want to change the timezone to fit your locale, you generally have two options. You can compute the local DateTime in your code or you can use WEBSITE_TIME_ZONE is the option you need.

First Option

This article explains how to convert the DateTime returned by Azure into your locale DateTime.

Second Option

Follow this article to set the correct timezone for your Azure App Service:

Look here for a list of the different timezones:

Conclusions

Azure makes developer life easy by allowing to easily set the timezone used to compute the server date time. Consider however summertime shifts and the effects that could have on your application if you are making calculations.

--

--

Alberto De Natale
Alberto De Natale

Written by Alberto De Natale

Alberto De Natale is a passionate tech-enthusiast software developer.

No responses yet