Category / Section
How to set 24 hours format DateTime in DateTimeEdit control
1 min read
To set the 24 hour format DateTime in DateTimeEdit control, the pattern of DateTimeEdit should set to CustomPattern. The same has been demonstrated in the following code example:
XAML:
<Window x:Class="NewText_WPfapplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" Title="MainWindow" Height="350" Width="525"> <Grid x:Name="Grid1"> <syncfusion:DateTimeEdit x:Name="Date1" Width="100" Height="23" Pattern="CustomPattern" CustomPattern="HH:mm" /> </Grid> </Window>
C#:
using Syncfusion.Windows.Tools.Controls; using Syncfusion.Windows.Shared; namespace NewText_WPfapplication { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DateTimeEdit Date1 = new DateTimeEdit(); Date1.Width = 100; Date1.Height = 23; Date1.Pattern = DateTimePattern.CustomPattern; Date1.CustomPattern = "HH:mm"; Grid1.Children.Add(Date1); }}}
Output:
The following output shows the time format which greater than 12 hours.