How to set default time zone in ASP.Net Applicatio

2019-02-21 23:19发布

问题:

Hi i have created the asp.net web application without considering the time zone. I am using directly the DateTime.Now function. Actually that returns datetime in server configured time zone format. Now i cant change entire application. so is there any way set the TimeZone of application independent of server in which it is hosted? or is there any way to set in web config file.

回答1:

TimeZone.CurrentTimeZone is used for the time zone on the computer where the code is executing. Check these links: http://msdn.microsoft.com/en-us/library/system.timezone.currenttimezone.aspx

http://msdn.microsoft.com/en-us/library/system.timezoneinfo.local.aspx