Use the Current DateTimePicker Culture Default Date Format as a Parse Format
Environment
Product | Progress® Kendo UI® DateTimePicker for jQuery |
Operating System | Windows 10 64bit |
Visual Studio Version | Visual Studio 2017 |
Preferred Language | JavaScript |
Description
How can I use the current default culture format as a parse format for the Kendo UI for jQuery DateTimePicker?
Solution
The default behavior of the DateTimePicker widget is to treat a value with no time part as invalid unless the corresponding format is provided in the parseFormats
option.
The following example demonstrates how to add the default short date format of the current culture to the parseFormats
array, so that when the time portion is removed from the DateTimePicker input, the value is still parsed as a valid date.
<script src="https://kendo.cdn.telerik.com/2023.2.829/js/cultures/kendo.culture.bg-BG.min.js"></script>
<input id="datetimepicker" />
<script>
kendo.culture('bg-BG');
$("#datetimepicker").kendoDateTimePicker({
parseFormats: [kendo.culture().calendar.patterns['d']],
change: function(e){
console.log(this.value());
}
});
</script>