Monday, November 3, 2008

Don't you just love when something is simple?

Dot .Net Dilemmas.

Recently I had to change my hosting provider (more about that later) and one of the issues that it caused was with a web application that was created for an Irish business.

The dates that were displayed and used in various searches needed to be in the format "dd/MM/yyyy" but because my new provider was based in the US, the hosting server reports in Pacific time. All of my code fell over and the searches produced the "String was not recognized as a valid DateTime." error.

I honestly felt that I was going to have to change a lot of code and set the CultureInfo but then I posted the question on Stackoverflow and the answer was oh so simple.

In your web.config file add the element under the node (if you don't already have one) and add the correct culture. In our case "en-gb".

<system.web>
<globalization culture="en-gb">
<!-- ... -->
</system.web>

No comments: