Reputation: 17701
I have got problem with setting date to kendo ui date picker, I am successfully able to set the today date by using the following code :
var todayDate = new Date();
$('#createdonend').data("kendoDatePicker").value(todayDate);
I am not able to set the yesterday date by using following code
var todayDate = new Date();
var yesterdayDate = todayDate.getDate() - 1;
$('#createdonbegin').data("kendoDatePicker").value(yesterdayDate);
for the above function I am getting error like this
Microsoft JScript runtime error: Object doesn't support this property or method in this file /Scripts/kendo/2013.2.716/kendo.all.min.js
would any one pls help on this one why i am getting this error for setting yesterday date to kendo ui datepicker..
Many thanks In advance..
Upvotes: 2
Views: 8049
Reputation: 40917
As @Niels said you have to use:
yesterdayDate.setDate(today.getDate() - 1);
for setting yesterday date but you need to have yesterdayDate
initialized to today's Date
before setting it to previous day since setDate
only sets the day of the month.
So, the proposed code is:
// Create a "date" object with today's date
var date = new Date();
// Changes the day of the month to previous, this keeps in mind month and year changes
date.setDate(date.getDate() - 1);
// Set the new date
$('#createdonbegin').data("kendoDatePicker").value(date);
Running example in JSFiddle: http://jsfiddle.net/OnaBai/v7UPr/
Upvotes: 2