Displaying AM & PM in date timepicker c#

Hemanth B 886 Reputation points
2021-06-09T04:06:23.39+00:00

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

Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Daniel Zhang-MSFT 9,651 Reputation points
    2021-06-09T05:20:54.163+00:00

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.