I need the time in AM/PM format in an ASP.NET MVC 3 application, and I am using the following statement:
@Model.ReportDate.ToString("hh:mm tt")
But it is returning 6:45 instead of 6:45 PM. How do I fix this?
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.
The format strings are culture/locale dependent so it may be using the settings from your server (e.g. 24 hour time). Try this:
If this (or something similar) solves your problem, I suggest setting the desired culture in
global.asaxso your entire app uses the culture you expect.