Change date time format of an ASP.NET web application

Having worked with ASP.NET websites for a couple of years, I often run into problems with different culture settings in development, staging and production servers.

For example, you develop an ASP.NET web application on your local PC and test on a staging server, both of which have Australia setup as their location. Now the application is about to be deployed to a production server. It is often the case that to save on running costs, the client chooses US-based shared servers over Australian-based ones. As a result, you notice that the site displays date in a different format – e.g. mm/dd/yyyy ( 12/25/2008 ) instead of dd/mm/yyyy ( 25/12/2008 ).

Of course as with many shared servers, you don’t have the privilege to change the global settings on the server as it would affect all other websites hosted on the box. A quick and easy way to overcome this is to add a setting to the web.config file:

<configuration>
<system.web>
<globalization culture="en-AU" uiCulture="en-AU" />
</system.web>
</configuration>

Further reading: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx

Advertisements

3 thoughts on “Change date time format of an ASP.NET web application

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s