I'm trying to load datetime and time string in process
DateTime strTime = DateTime.ParseExact(strTime.Trim(), "dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
I have several places to process date time string, from dateTimePicker:
UseDate = dateTimePicker1.Value.ToString("MMMM dd, yyyy - dddd");
with writing and then loading from the file:
dateTimePicker3.Value = DateTime.ParseExact(DB, "yyyy-MM-dd", CultureInfo.InvariantCulture);
it works proper with english, but not sure how to prevent if user have different setting like chinese or russian, in this case I got:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: String was not recognized as a valid DateTime.
I can prevent input with different punctuation with replace "/", ".", and remove all words from string, but in this case I'm not sure how to figure out proper way.
For example, in debug I see strTime with russian "апреля 10, 2017 - понедельник" string, but how to change it to correct readable date without words. I can't process it with regular expression, because in result I can get something like 102017 or at least 10.20.17 but not 10 April of 2017 which must be 10.04.2017 or 10/04/2017 or 10-04-2017 or even in different order 4/10/2017 etc