Possible Duplicate:
Convert string to DateTime in c#
How can I convert string to DateTime by a format?
Convert.ToDateTime("12/11/17 2:52:35 PM")
Result is 12/11/2017 02:52:35 PM
and this is incorrect because
my expect is 11/17/2012 02:52:35 PM
You're looking for DateTime.ParseExact()
.
DateTime.ParseExact(myStr, "yy/MM/dd h:mm:ss tt", CultureInfo.InvariantCulture);
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