I'm trying to change the default time zone of my asp.net website and i tried the following code but it didn't 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>
Changing the culture does not change the time zone. There is no way in .NET to change the time zone on a per-application basis. It can only be changed system-wide.
Many servers set it to UTC, but the best practice is to not rely on the system time zone at all. Never use DateTime.Now
, TimeZoneInfo.Local
, DateTimeKind.Local
, etc. from a web application.
Instead, use DateTime.UtcNow
, DateTimeOffset.UtcNow
, or if you must know the server's local time, use DateTimeOffset.Now
.
If you need a particular user's local time, then you need to know their time zone, and use the functions on TimeZoneInfo
to convert between that specific zone and UTC.
Read more here.
You will need to change the time zone of the server in which your database is hosted. You cannot do it through web.config.
Having the date/time stored in UTC format is a best practice. Refer to this article below.
http://www.4guysfromrolla.com/articles/081507-1.aspx
Hope this helps.
(source: http://forums.asp.net/post/5060690.aspx)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With