In UWP, formatting a date as a longdate string like this
string myDateString = new DateTimeFormatter("longdate").Format(DateTime.Today);
gives myDateString = "Thursday, 12 October 2017"
Trying to convert it back like this
DateTime myDate = DateTime.Parse(myDateString, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal);
throws System.FormatException
Trying to convert it back like this
DateTime myDate = DateTime.ParseExact(myDateString, "longdate", CultureInfo.CurrentCulture);
Also throws System.FormatException
I then set my machine to US. The value of myDateString = "Thursday, October 12 2017"
but when I try it convert it back to a datetime this also throws a System.FormatException
.
How should I convert a long date string to a datetime in C# using the current culture?