user2456335
user2456335

Reputation: 11

kendodatetimepicker selects wrong date

when I set the Minimum date as Today for Kendo UI DateTimePicker and when I select the current date from the calendar it selects the wrong date(when selected 06/05/2013 it displays as 07/05/2013).check this fiddle http://jsfiddle.net/n6GtT/12/

 var start = $("#start").kendoDateTimePicker({
                    //value: today,
                    max:today,
                    change: startChange,
                    parseFormats: ["MM/dd/yyyy"]
                }).data("kendoDateTimePicker");

                var end = $("#end").kendoDateTimePicker({
                    //value: today,
                    min:today,
                    change: endChange,
                    parseFormats: ["MM/dd/yyyy"]
                }).data("kendoDateTimePicker");

                start.max(end.value());
                end.min(start.value());
            });

Thanks

Upvotes: 1

Views: 2004

Answers (1)

Brett McCarty
Brett McCarty

Reputation: 399

This is an issue with the today variable that you are setting. By removing the formatting of today's date you get the expected behavior.

Here is the updated fiddle.

So this:

var today = new Date(kendo.format('{0:MM-dd-yyyy}', new Date()));

Becomes:

var today = new Date();

This most likely has to do with Kendo parsing the date twice. Once in the kendo.format() and once in the kendoDatePicker.

Months in JavaScript are zero based and need to be incremented to reflect the correct date.

Upvotes: 1

Related Questions