Reputation: 1468
i'm designing a form which takes passengers' information. i need their birth dates so i'm using datepicker tool.
here is my code:
$('#datepickerBirth').datepicker({
inline: true,
changeYear: true,
changeMonth: true,
dateFormat: 'MM dd, yy',
showOtherMonths: true
});
$("#datepickerBirth").datepicker("setDate", "10/12/1986");
code works well but not the date. it shows january 12,2019 when i run project. but i set my date to another one. where am i doing wrong?
Upvotes: 0
Views: 1874
Reputation: 4168
$(function() {
var myDate = new Date(1986,12,10);
$('#datepicker').datepicker();
$('#datepicker').datepicker('setDate', myDate);
});
Try it like this
Upvotes: 1
Reputation: 3844
$('#datepickerBirth').datepicker("setDate", new Date(1986,10,12) );
Upvotes: 3
Reputation: 539
The new date may be a Date object or a string in the current date format - your format is 'MM dd, yy'
var myDate = new Date(1986,10,12)
$('#datepicker').datepicker('setDate', myDate);
Upvotes: 1