format the time in DateTimePicker

AMER SAID 396 Reputation points
2021-08-04T18:46:32.803+00:00

I want to format the time DateTimePicker to 24 hours.

I used the following code and the time is actually changed to 24 hours. The problem now is that the date format takes an undesirable shape when using an Arabic region for the device or an English region. I want the direction of the date to not change no matter how different the region of the device.

I want the direction of the date to be an hour and a minute and am pm as in the picture, regardless of the time zone

120593-untitled2.png

 If Thread.CurrentThread.CurrentCulture.DisplayName.Contains("arab".ToLower)  Then  
                    ROSYUPDATE_F.DateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom  
                    ROSYUPDATE_F.DateTimePicker.CustomFormat = "HH:mm tt"   
                Else  
      
                    ROSYUPDATE_F.DateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom  
                    ROSYUPDATE_F.DateTimePicker.CustomFormat = " tt mm:HH"  
                End If  

Animation that changes the time from the desired format

120582-untitled.gif

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,599 questions
0 comments No comments
{count} votes