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?
By default, on Azure App Service, the time zone is always UTC, but you can change it.
You cannot change the location of an app service plan, regardless of subscription type. You simply need to create a new app service plan in the region you want, and then redeploy your code.
By default, all Azure DevOps organizations and user accounts are set to UTC (Coordinated Universal Time) irrespective of what zones they are hosted in. Even if your organization migrated from an on-premises server to Azure DevOps Services, your timezone is set to UTC time.
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".
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With