Kim-Jimin
Kim-Jimin

Reputation: 694

How to change default time zone in azure website service?

I'm new to Azure Web Sites service. I uploaded my web site files and it works very nice.

But I have a problem with default time zone. My location is Seoul(+9). But the code return UTC(+0) time when I call below.

DateTime.Now;

Is there any way to solve this problem without complicated fix like editing Web.config?

Upvotes: 20

Views: 29536

Answers (2)

Tom Hollander
Tom Hollander

Reputation: 693

It is now possible to change the server time zone for your Azure Websites / Web Apps.

To do this, add an application setting (using the portal) called “WEBSITE_TIME_ZONE” equal to the name of the time zone in question (basically the same string as the key name at HKLM\Software\Microsoft\Windows Nt\CurrentVersion\Time Zones\).

The list of time zone values is here. Use a value from the column labeled "Name of Time Zone".

Upvotes: 49

pabdulin
pabdulin

Reputation: 35229

Changing TimeZone on Azure VMs is not recommended according to Microsoft. Instead convert time to local using methods of TimeZoneInfo structure.

However at least one possible solution is mentioned in the above mentioned post.

P.S. an example of solution provided by question author in comment below:

DateTime timeUtc = DateTime.UtcNow;
TimeZoneInfo kstZone = TimeZoneInfo.FindSystemTimeZoneById("Korea Standard Time"); 
DateTime kstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, kstZone);

Upvotes: 13

Related Questions