I’m using c#, and if I do
DateTime.ParseExact("4/4/2010 4:20:00 PM", "M'/'d'/'yyyy H':'mm':'ss' 'tt", null)
The return value is always 4:20 AM — what am I doing wrong with using tt?
Thanks!
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.
Make the hour format (
H) lowercase like this:Uppercase “H” indicates 24-hour time and lowercase “h” indicates 12-hour time and will respect the AM/PM in the candidate string.
Side note: It is best to provide an instance of
IFormatProviderto methods like this (even if it’s justCultureInfo.InvariantCulture). It’s one of those things that doesn’t really matter until you hit problems with it so it can be good to be in the habit of specifying culture information.