您的位置:首页 > 其它

Azure Website - UTC Time and Local Time

2015-11-24 17:39 337 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: