# ASP.NET Core DateTimePicker Overview

The Telerik UI DateTimePicker TagHelper and HtmlHelper for ASP.NET Core are server-side wrappers for the Kendo UI DateTimePicker widget.

The DateTimePicker allows the user to select a value from a calendar, a time drop-down list, or through direct input.

* [Demo page for the DateTimePicker HtmlHelper](https://demos.telerik.com/aspnet-core/datetimepicker/index)

* [Demo page for the DateTimePicker TagHelper](https://demos.telerik.com/aspnet-core/datetimepicker/tag-helper)

## Initializing the DateTimePicker

The following example demonstrates how to define the DateTimePicker.

> The DateTimePicker copies any styles and CSS classes from the input element to the wrapper element.

```Razor HtmlHelper
    @(Html.Kendo().DateTimePicker()
        .Name("dateTimePicker")
    )
```

```Razor TagHelper
    <kendo-datetimepicker name="dateTimePicker"></kendo-datetimepicker>
```

> Starting with the 2024 Q3 release, the HtmlHelper version of the component supports [declarative initialization](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/helper-basics/declarative-initialization).

## Basic Configuration

The DateTimePicker configuration options are passed as attributes.

```Razor HtmlHelper
    @(Html.Kendo().DateTimePicker()
        .Name("end")
        .Value(DateTime.Today)
        .Min(DateTime.Today)
    )
```

```Razor TagHelper
    <kendo-datetimepicker name="end" value="DateTime.Today"
        min="DateTime.Today">
    </kendo-datetimepicker>
```

The `ParseFormats` option is of type `string[]` and can be assigned either by a `ViewBag` property or by a property of the model.

```Razor HtmlHelper
    @(Html.Kendo().DateTimePicker()
        .Name("datetimepicker")
        .ParseFormats(new string[] { "MMMM yyyy", "MMMM" })
    )
```

```Razor TagHelper
    @{
        ViewBag.ParseDates = new string[] { "MMMM yyyy", "MMMM" };
    }

    <kendo-datetimepicker name="datetimepicker" parse-formats="ViewBag.ParseDates">
    </kendo-datetimepicker>
```

## Model Binding

The DateTimePicker component respects DataAnnotations when the `DateTimePickerFor(m=>m.Property)` method is used. Besides the `[Required]` attribute, the `[DisplayFormat]` and `[Range]` attributes are also supported. The [`Format`](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/datetimepickerbuilder#formatsystemstring) configuration will be set to the provided DisplayFormat and the [`Min`](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/datetimepickerbuilder#minsystemstring) and [`Max`](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/datetimepickerbuilder#maxsystemstring) configurations will be set based on the range provided.

```Razor HtmlHelper
    @(Html.Kendo().DateTimePickerFor(m=>m.MyDateTimeProperty))
```

```Razor TagHelper
    <kendo-datetimepicker for="MyDateTimeProperty"
    </kendo-datetimepicker>
```

```C#
    [Required]
    [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
    [Range(typeof(DateTime), minimum:"01/01/2023", maximum:"31/12/2023")]
    public DateTime MyDateTimeProperty{ get; set; }
```

## Functionality and Features

| Feature                                                                                                                                  | Description                                                                                                                                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Disabled dates](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/disabled-dates)                | The DateTimePicker allows you to disable specific days that shouldn't be selected by the end user, such as weekends and national holidays.                                                                                                                    |
| [Component Type](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/component-type)                | The DateTimePicker allows you to choose between two rendering options: standard and modern appearance.                                                                                                                                                        |
| [Selected dates](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/selected-dates)                | The DateTimePicker allows you to render a pre-selected date and also define the minimum and maximum dates it displays.                                                                                                                                        |
| [Start view and navigation depth](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/nav-depth)    | The DateTimePicker enables you to set the rendered initial view and define the navigation depth of the views.                                                                                                                                                 |
| [Interval](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/interval)                            | You can configure the interval between the time values.                                                                                                                                                                                                       |
| [Floating Labels](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/floating-label)               | You can explicitly set a floating label which floats above the field and remains visible.                                                                                                                                                                     |
| [Validation](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/validation)                        | The DateTimePicker does not automatically update the typed text when the typed text is invalid. Such changes in the input value may lead to unexpected behavior.                                                                                              |
| [Date and time formatting](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/datetime-formatting) | The DateTimePicker allows you to define its date and time formatting.                                                                                                                                                                                         |
| [Calendar types](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/calendar-types)                | By default, the DatePicker works with `Date` objects which support only the [Gregorian](https://en.wikipedia.org/wiki/Gregorian_calendar) calendar.                                                                                                           |
| [Week number column](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/week-num-column)           | The DateTimePicker provides options for rendering a column which displays the number of the weeks within the current `Month` view.                                                                                                                            |
| [Templates](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/templates)                          | The DateTimePicker provides options for using and customizing its templates.                                                                                                                                                                                  |
| [Globalization](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/globalization/overview)         | The DateTimePicker comes with globalization support that allows you to use the component in apps all over the world.                                                                                                                                          |
| [Accessibility](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/accessibility/overview)         | The DateRangePicker is accessible for screen readers, supports WAI-ARIA attributes, and delivers [keyboard shortcuts](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/daterangepicker/accessibility/key-nav) for faster navigation. |
| [Automatic Correction](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/auto-adjust)             | You can configure whether the component will autocorrect the user's input when the `Min` and `Max` values are set.                                                                                                                                            |

## Next Steps

* [Getting Started with the DateTimePicker](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/getting-started)

* [Basic Usage of the DateTimePicker HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/datetimepicker/index)

* [Basic Usage of the DateTimePicker TagHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/datetimepicker/tag-helper)

* [DateTimePicker in Razor Pages](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/datetimepicker/razor-pages)

## See Also

* [Using the API of the DateTimePicker for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/datetimepicker/api)
* [Knowledge Base Section](https://www.telerik.com/aspnet-core-ui/documentation/knowledge-base)
