C# DateTime.Now in Azure not reporting GMT - can the default timezone be set?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 05:28:34

First, GMT is essentially the same as UTC - it has no offset. To be precise, UTC supersedes GMT . You are probably confusing it with BST which is GMT+1:00 during summer time.

In general, it's a bad idea to make assumptions about timezones, especially in web applications. Instead of DateTime you should use DateTimeOffset.

Luckily, there was a recent change for Azure Web Sites and now you can change the timezone of an Azure Web site in a supported and reliable way. From the MSDN blog post

All you need to do is add an Application Setting (via the portal or the management APIs) called WEBSITE_TIME_ZONE and set that to the name of the time zone as defined in the Windows Registry under HKLM\Software\Microsoft\Windows Nt\CurrentVersion\Time Zones\ (for example, “AUS Eastern Standard Time”).

Unfortunately, Windows mixes up the timezones and uses the name "GMT Standard Time" to refer to BST and "UTC" to refer to GMT/UTC.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!