I am trying to convert a string of the below format dd/MM/yyyy hh:mm:ss.fff into DateTime value
easiest way?
BTW
IFormatProvider culture = new CultureInfo("en-US", true);
DateTime.ParseExact(timeString, "dd/MM/yyyy hh:mm:ss.fff",culture);
Throws an invalid time exception
Eg. 11/12/2009 13:30:00.000 Where 12 is the month (i know weird)
You have to use HH
string timeString = "11/12/2009 13:30:00.000";
IFormatProvider culture = new CultureInfo("en-US", true);
DateTime dateVal = DateTime.ParseExact(timeString, "dd/MM/yyyy HH:mm:ss.fff", culture);
hh:mm:ss.fff
should be HH:mm:ss.fff
since you're using 24-hour format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With