I have this in my code:
var date1 = DateTime.ParseExact(date, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
And when my current cultur is dutch (nl-NL
) instead of May 1st I get January 5th.
I think the error is in the second parameter dd.MM.yyyy HH:mm:ss
.
Is there a way to fix this using the CultureInfo
class?
You may try the following:
System.Globalization.CultureInfo cultureinfo =
new System.Globalization.CultureInfo("nl-NL");
DateTime dt = DateTime.Parse(date, cultureinfo);