Time Formatting in WPF TimePicker (SfTimePicker)

The SfTimePicker control allows the user to select and display the time in various formats.

Display the time using the FormatString

We can edit and display the selected time with various formatting like short time, long time, universal time and 24 hour time formats by using the FormatString property. The default value of FormatString property is "h:mm tt".

<syncfusion:SfTimePicker x:Name="sfTimePicker" 
                         FormatString="HH:mm:ss"/>
SfTimePicker sfTimePicker = new SfTimePicker();
sfTimePicker.FormatString = "HH:mm:ss";

SfTimePicker with 24 hour time format

Here, SfTimePicker with 24 hour time format

Specifying format for the TimeSelector

We can allow the user to select the pair of hour, minutes, seconds and meridiem selector or any single selector cell from the SfTimeSelector by using the SelectorFormatString property. The default value of SelectorFormatString property is "h:mm tt" and the hour, minutes and meridiem value selector is enabled in the SfTimeSelector.

<syncfusion:SfTimePicker x:Name="sfTimePicker" 
                         SelectorFormatString="M"/>
SfTimePicker sfTimePicker = new SfTimePicker();
sfTimePicker.SelectorFormatString = "M";

SfTimePicker contains only hour and meridiem value selector

Here, we can only able to select the hour and meridiem value from the SfTimeSelector

Click here to download the sample that showcases the edit, display time formatting and time selection formatting by the SfTimePicker.

NOTE

A detailed explanation of standard time formatting is available here. The result string produced by these format specifiers are influenced by the settings in the Regional Options control panel. Computers with different cultures or different time and time settings will generate different result strings.