Populate DateTime from a string
I would like to populate a DateTime structure from a string, but it is not working: This is the format开发者_如何学JAVA I have: i.e.: "6/4/09 11:10 AM"
This is what I am using but it is not working DateTime dttm = DateTime.ParseExact(dttmString, "d/m/yy H:mm tt", format);
Any idea? Thanks
Tony
It's your month. Month is "M". "m" is minutes. "H" is 24 hour time. Here's a reference page for datetime.parseextact and datetime.tostring format strings. http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm
use "d/M/yy h:mm tt", format);
Change 'm' to 'M' for month and change 'H' to 'h' for hour.
try using a capital 'M' for month.
精彩评论