question

HemanthB-9452 avatar image
0 Votes"
HemanthB-9452 asked HemanthB-9452 commented

Displaying AM & PM in date timepicker c#

I want the datetimepicker in C# WinForm apps to display AM & PM after the time in the datetimepicker. How do I do that?

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered HemanthB-9452 commented

Hi HemanthB-9452,
You can use DateTimePicker.CustomFormat property to set the custom date/time format string.

 private void Form1_Load(object sender, EventArgs e)
 {
     dateTimePicker1.Format = DateTimePickerFormat.Custom;
     dateTimePicker1.CustomFormat = "MM'/'dd'/'yyyy hh':'mm tt";
 }

And the "tt" character is read as a two-letter AM/PM format string.
More details please refer to this document.
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks so much

0 Votes 0 ·