Blog Stats
  • Posts - 170
  • Articles - 4
  • Comments - 54
  • Trackbacks - 7

 

Date format and CultureInfo

I am sharing this because it can be useful for a lot of developers dealing with date format issues in their projects.

I was writing some code to get back some date ranges and everything was working well on my machine. But the deployment failed on the production server for the reason that the OS was installed as an English American language.

The signature for that is en-US when obviously it is en-IE for Ireland. This is causing also some problems with the SQL boc, so an advice check before installing SQL Server that you have the right language option.

OK back to my code what I have done is to use the CultureInfo method you can find in the Globalization class to force the date format as an Irish one.

Here we go in C# :

DateTime myDate = Convert.ToDateTime(lst.SelectedItem.ToString(), new System.Globalization.CultureInfo("en-IE"));

here is a small list of the possible english cultures:

Culture Name Culture Identifier Language-Country/Region

en 0x0009 English
en-AU 0x0C09 English - Australia
en-BZ 0x2809 English - Belize
en-CA 0x1009 English - Canada
en-CB 0x2409 English - Caribbean
en-IE 0x1809 English - Ireland
en-JM 0x2009 English - Jamaica
en-NZ 0x1409 English - New Zealand
en-PH 0x3409 English - Philippines
en-ZA 0x1C09 English - South Africa
en-TT 0x2C09 English - Trinidad and Tobago
en-GB 0x0809 English - United Kingdom
en-US 0x0409 English - United States
en-ZW 0x3009 English - Zimbabwe

 


Feedback

# re: Date format and CultureInfo

Gravatar I had the same problem. On a project, users can create their own Html-elements and show values from their tables. But the output depends on the language-setting of the client: Date 24.12.2000 or 12/24/2000?

To see which values are the same in each specific culture (en-AU, en-BZ ...), the link above has 68 pages for each of the 68 neutral cultures and lists most properties.

It was nice to see what differences exists between the five german specific cultures. 7/7/2005 9:39 PM | Juergen Auer

Comments have been closed on this topic.
 

 

Copyright © Paschal L