Reputation: 8266
I have the following code which attaches the jQuery UI date picker widget to an input field:
console.log($("#profileDialog .date-picker").val());
$("#profileDialog .date-picker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd',
yearRange: "-115:-2",
defaultDate: $("#profileDialog .date-picker").val()
});
The console log outputs the value correctly (ex: 11/1/1955 12:00:00 AM
), but when I click inside the input field, the date picker shows me a selected date of April 17 1897
.
Any ideas why this might be happening?
Upvotes: 1
Views: 1113
Reputation: 20250
The reason you see 1897
as the year is because you're setting the dateFormat
as yy-mm-dd
, when the default date is in the format dd-mm-yy
, which isn't a valid date (in the given format).
Upvotes: 2