首页 > Web开发 > 详细

Azure Website - UTC Time and Local Time

时间:2015-11-24 21:16:30      阅读:304      评论:0      收藏:0      [点我收藏+]


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

原文:http://blog.csdn.net/jameszhou/article/details/50016175

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!