I have a string
and when I try to convert that to a DateTime
it's throwing an error. Why?
string str = "3/23/2016 5:10:32 PM";
datetime= convert.ToDateTime(str);
I have a string
and when I try to convert that to a DateTime
it's throwing an error. Why?
string str = "3/23/2016 5:10:32 PM";
datetime= convert.ToDateTime(str);
Convert.ToDateTime
should work fine if your current culture allows this.
You however have some strange characters in your string... I have copied and pasted it and it didn't work, however writing it directly did.
Check it in a fiddle: https://dotnetfiddle.net/l5nzso
It seems you have some left-to-right mark (0x200E) Unicode characters scattered between the characters in your string. Check it in this other fiddle