postgresnewbie
postgresnewbie

Reputation: 1468

can't set jQuery DatePicker to specific date

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

Answers (3)

SergkeiM
SergkeiM

Reputation: 4168

$(function() {
var myDate = new Date(1986,12,10);
$('#datepicker').datepicker();
$('#datepicker').datepicker('setDate', myDate);
});

Try it like this

Upvotes: 1

Janith Chinthana
Janith Chinthana

Reputation: 3844

$('#datepickerBirth').datepicker("setDate", new Date(1986,10,12) );

Upvotes: 3

li-on
li-on

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

Related Questions