Azure local time is incorrect for all but web server's time zone

OzCoder2 21 Reputation points
2020-06-12T09:52:54.273+00:00

Our Azure web app is located in Australia East. Regardless of where the user is located, the web server's local time is reported. I have tried a number of methods including:

TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.Local)

but nothing works. Substituting TimeZoneInfo.Local with TimeZoneInfo.FindSystemTimeZoneById() makes no difference.

How do I configure the web app to return the local time in any time zone?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,284 questions
0 comments No comments
{count} votes

Accepted answer
  1. ajkuma 27,946 Reputation points Microsoft Employee
    2020-06-22T07:06:57.877+00:00

    @OzCoder2-5058, Please accept my sincere apologies for a delayed response.

    By default, on Azure App Service, the time zone is always UTC, but you can change it.

    If you haven't done this already, you need to set WEBSITE_TIME_ZONE variable in Application settings > under App settings, add this setting:

    o Key = WEBSITE_TIME_ZONE
    o Value = The time zone you want

    Save, the above settings and then check.

    For the App services that run on Windows, see the Timezone column in the Default Time Zones article for accepted values. For the App services that run on Linux, set the TZ database name as the time zone value.

    In the code, the DateTime.Now() method will return local time instead of the default UTC.

    Note: This should affect most of the APIs but it won't change the IIS logs time zone. They will remain in UTC.

    Kindly let us know if this works or you need further assistance , we would be more than happy to help further.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. OzCoder2 21 Reputation points
    2020-06-27T04:11:50.693+00:00

    @ajkuma-MSFT, thank you for your reply but I have already tried setting WEBSITE_TIME_ZONE and it makes no difference. Our NZ users always see Australian time.

    In principle, should TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.Local) work?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.