I know we can do the following to show AM PM for a Time.
String.Format("{0:t}", dt); // "4:05 PM"
What if I want to show A for AM and P for PM. Is there a format for that?
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.
Another solution would be to use the System.Globalization.DateTimeFormatInfo class which allows you to specify how you want your AM/PM to be formatted:
You can do completely custom stuff with it:
Example output for 4:05 PM: