3

I set the format of my date in this way:

$('#filterdate').kendoDatePicker({format: "dd/MM/yyyy"});

SOMEWHERE I have code which set (#filterdate)

#filterdate is 10/7/2014

but when I use this code :

$('#filterdate').data("KendoDatePicker").value();

it returns : 10 Jun 2014

why the dates are different? its really strange. I think I have problem in initializing Kendo (maybe) .

OnaBai
  • 40,767
  • 6
  • 96
  • 125
Sara N
  • 1,079
  • 5
  • 17
  • 45

1 Answers1

5
  • First important question about dates is that months (as @LarsHöppner) already noted are base 0.
  • Second, depending on your language/country settings -if you are using others than defaults- you might need to use both parseFormats (used when you set a date) and format (used for displaying the date in the input box).
  • Third, there is a typo error in $('#filterdate').data("KendoDatePicker").value(); where KendoDatePicker is with lowercase K, but since you say that it shows a date instead of complaining by an undefined, it is fine.

Said so, if you initialize the DatePicker as:

var fd = $("#filterdate").kendoDatePicker({
    parseFormats:["dd/MM/yyyy"],
    format: "dd/MM/yyyy"
}).data("kendoDatePicker");

it works perfectly fine, both setting and getting a date as:

Setting:

fd.value("10/7/2014");

and Getting:

var value = fd.value();

Check it running here: http://jsfiddle.net/OnaBai/5q1tnh1j/

OnaBai
  • 40,767
  • 6
  • 96
  • 125
  • How Can I thank You. YES. It works! just for formatting when I want to get data. so many thanks :) – Sara N Aug 08 '14 at 06:05