Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 3.32 KB

File metadata and controls

76 lines (57 loc) · 3.32 KB
layout title description platform control publishingplatform documentation
post
Date Time Format in
Learn here all about Date Time Format in Syncfusion
ej2-asp-core-mvc
Date Time Format
ug

DateTime Format

DateTime format is a way of representing the date and time value in different string format in textbox.

By default the DateTimePicker's format is based on the culture. You can also set the own custom format by using the format property.

N> Once the date format property has been defined it will be common to all the cultures.

To know more about the date and time format standards, refer to the Internationalization Date Time Format section.

The following example demonstrates the DateTimePicker with the custom format (yyyy-MM-dd hh:mm).

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %} {% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/datetimepicker/date-time-format/tagHelper %} {% endhighlight %} {% highlight c# tabtitle="Date-time-format.cs" %} {% include code-snippet/datetimepicker/date-time-format/date-time-format.cs %} {% endhighlight %} {% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %} {% highlight razor tabtitle="CSHTML" %} {% include code-snippet/datetimepicker/date-time-format/razor %} {% endhighlight %} {% highlight c# tabtitle="Date-time-format.cs" %} {% include code-snippet/datetimepicker/date-time-format/date-time-format.cs %} {% endhighlight %} {% endtabs %} {% endif %}

Input formats

The inputFormats property in the DatetimePicker control allows users to enter dates and times in various formats, providing flexibility in date and time entry. This property accepts an array of predefined formats that the control recognizes, enabling users to input dates in different ways while ensuring they are parsed correctly.

When the user types the date and time in any of the specified input formats, it will be automatically converted to the display format after pressing Enter, the Tab key, or when the input loses focus. This enhances the user experience by allowing intuitive data entry through various custom input formats.

The following example demonstrates the DateTimePicker with multiple input formats.

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %} {% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/datetimepicker/input-format/tagHelper %} {% endhighlight %} {% highlight c# tabtitle="Input-format.cs" %} {% include code-snippet/datetimepicker/input-format/input-format.cs %} {% endhighlight %} {% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %} {% highlight razor tabtitle="CSHTML" %} {% include code-snippet/datetimepicker/input-format/razor %} {% endhighlight %} {% highlight c# tabtitle="Input-format.cs" %} {% include code-snippet/datetimepicker/input-format/input-format.cs %} {% endhighlight %} {% endtabs %} {% endif %}