admin管理员组文章数量:1431420
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..
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..
Share Improve this question asked Sep 23, 2013 at 14:48 Glory RajGlory Raj 17.7k27 gold badges111 silver badges214 bronze badges2 Answers
Reset to default 2As @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/OnaBai/v7UPr/
You will need to use the following:
yesterdayDate.setDate(today.getDate() - 1);
getDate
will get the number of days in the month, not a Date
object.
The value returned by getDate is an integer between 1 and 31.
Sources:
- getDate
本文标签: javascriptnot able to set the yesterday date to kendo ui datepickerStack Overflow
版权声明:本文标题:javascript - not able to set the yesterday date to kendo ui datepicker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745574549a2664249.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论