简体   繁体   中英

What do I need to parse the date correctly

I'm receiving a bad parsing from the content in a database.

This is what I'm receiving and the date string.

FORMAT EXCEPTION: The string was not recognized as a valid DateTime. There is an unknown word starting at index 20.

11/02/2013 12:30:44 pm

I'm using DateTime.Parse(...) , what do I need to change to perform the parsing?

use DateTime.ParseExact()

DateTime x = DateTime.ParseExact("11/02/2013 12:30:44 p.m.", "dd/MM/yyyy hh:mm:ss tt", null)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM