Azure Website - UTC Time and Local Time


Key: Azure Website uses UTC time on the server

How to: show local time in website UI?

Solution:

#1 Use TimeZoneInfo to convert UTC to local time

var cetZone = TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time");         
var localTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, cetZone);

#2 Use app settings to always show local time in Azure Management

   in app settings, add the TimeZoneInfo Id value to the WEBSITE_TIME_ZONE attribute, then, the DateTime.Now() method will return local time instead of the default GMT

reference - http://blogs.msdn.com/b/waws/archive/2014/08/05/get-the-local-server-time-for-your-azure-web-site.aspx

你可能感兴趣的:(Azure Website - UTC Time and Local Time)