How to change default timezone for my asp.net site in web.config file

I am trying to change the default time zone on my asp.net website and I tried the following code, but it did not work.

<system.web> <globalization culture="ar-JO" uiCulture="ar-JO" /> <httpRuntime maxUrlLength="10999" maxQueryStringLength="2097151" /> <compilation debug="true" targetFramework="4.0"/> <customErrors mode="Off"/> <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> 

+7
timezone web-config
source share
2 answers

A change in culture does not change the time zone. There is no way in .NET to change the time zone for each application. It can only be changed within the entire system.

Many servers install it in UTC, but it is best not to rely on the system time zone. Never use DateTime.Now , TimeZoneInfo.Local , DateTimeKind.Local , etc. From a web application.

Instead, use DateTime.UtcNow , DateTimeOffset.UtcNow or, if you know the local server time, use DateTimeOffset.Now .

If you need a specific local user time, you need to know their time zone and use the TimeZoneInfo functions to convert between this specific zone and UTC.

More details here .

+18
source share

You will need to change the time zone of the server on which your database is hosted. You cannot do this through web.config.

Having a date / time stored in UTC is best practice. See this article below.

http://www.4guysfromrolla.com/articles/081507-1.aspx

Hope this helps.

(source: http://forums.asp.net/post/5060690.aspx )

+1
source share

All Articles