3

Is there some kind of list of all common Date (and Time) formats? One of our customers had a problem inputting a date, because he was using something like this: 2003. 11. 9.

I already found this very good wiki page: http://en.wikipedia.org/wiki/Date_format_by_country

I am only looking for european countries and relevant formats. Another possibility would be to use C# and change the CultureInfo to print out the short date pattern I guess.

Maybe someone has better ideas or can help me find other solutions.

nawfal
  • 70,104
  • 56
  • 326
  • 368
Marc
  • 1,531
  • 1
  • 11
  • 14

1 Answers1

2

You can get it programmatically like this:

//by culture
var formats = CultureInfo.GetCultures(CultureTypes.AllCultures)
    .ToDictionary(x => x.Name, x => x.DateTimeFormat.GetAllDateTimePatterns());

//or by country (only specific cultures has region/country info)
var formats = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
    .GroupBy(x => new RegionInfo(x.Name).DisplayName)
    .ToDictionary(x => x.Key, x => x.SelectMany(y => y.DateTimeFormat.GetAllDateTimePatterns()).Distinct().ToArray());

For reference, this is the most comprehensive I've found

nawfal
  • 70,104
  • 56
  • 326
  • 368
  • 1
    I just tried to check out your reference link and found it dead. Do you have any other similar references? – Casper Wilkes Jan 24 '16 at 21:47
  • Code doesnt prove anything, only how Microsoft and/or you have decided to set up CultureInfo objects on the machine you run this code on – Andrew Bullock Apr 06 '16 at 18:13
  • @AndrewBullock How can *I* set up culture info objects on my machine, given the above code? I am not using just any one of the machine specific regions or cultures, but iterating through every culture MS has to offer. How is that me setting it up? – nawfal Apr 07 '16 at 01:26