My machine is configured with European date format: dd/MM/yyyy
When running any of the following lines:
DateTime.Parse("11/15/2017 12:00:00 AM");
DateTime.Parse("11/15/2017 12:00:00 AM", CultureInfo.CreateSpecificCulture("en-US"));
DateTime.Parse("11/15/2017 12:00:00 AM", CultureInfo.CreateSpecificCulture("fr-FR"));
DateTime.Parse("11/15/2017 12:00:00 AM", CultureInfo.CreateSpecificCulture("en-GB"));
I'm getting
System.FormatException: String was not recognized as a valid DateTime.
Why doesn't any culture info allow me to parse this date? I know in which culture the string was originally created (using DateTime.ToString()
), but that's it, so I don't want to use ParseExact
, unless there is some API to get the default format string per culture.