Reputation: 1635
setting default date does not showing the month I set, but the month +1
var defaultDateA1 = new Date(2014,7,1)
$('#DRdatepicker').datepicker();
$('#DRdatepicker').datepicker('setDate', defaultDateA1);
//whole code below in not working as well
$( "#DRdatepicker" ).datepicker({
readonly: true,
//setDate: new Date(2014,7,1), // First tried here, didn't work
dateFormat: 'yy-mm-dd',
autoSize: true
});
It is showing 08/01/2014
Upvotes: 1
Views: 524
Reputation: 133403
Read Docs
month: Integer value representing the month, beginning with 0 for January to 11 for December.
So you have to use
var defaultDateA1 = new Date(2014,7 - 1, 1)
With Date format:
$("#DRdatepicker").datepicker({
readonly: true,
dateFormat: 'yy-mm-dd',
autoSize: true
}).datepicker('setDate', new Date(2014, 7 - 1, 1));
Upvotes: 2