2/22/2012 3:30:00
Surely that is an acceptable format to be converted to DateTime using Convert.ToDateTime()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would personally avoid using
Convert.ToDateTime. I generally prefer1 to useDateTime.TryParseExact, specifying the culture and format string you expect – assuming you have an expected format, of course. If you don’t, you have to ask yourself bigger questions.For example:
That’s a slightly odd format to start with – normally a 24-hour format would include a leading 0 for the hour, and a 12-hour format would include an am/pm designator.
1 Well, I prefer to use Noda Time, but that’s a different matter…