Ok so after some research I haven't found any way to solve my problem .
This is my String to Date conversion code:
DateTime startDate = new DateTime();
startDate = DateTime.ParseExact(this.items[5], "dd/MM/yyyy HH:mm:ss",
CultureInfo.InvariantCulture);
And this is the string I want to convert:
"22/2/2013 09:57:32"
But when I compile I have this error:
String was not recognized as a valid DateTime.
What should I do?
Your pattern should be "dd/M/yyyy HH:mm:ss"
MM
requires leading 0, which is not provided in your input string.
You need a single M
instead of MM
for month . So format should be: "dd/M/yyyy HH:mm:ss"
Just 只需要 EX:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.