问题
When I select a date on the datepicker, I need it to default to yyyy/mm/dd
When I do the following:
$(id).datepicker("option", "dateFormat", 'yyyy/mm/dd');
and select a field, the datepicker does not even come up.
Is there anything wrong with what I have above?
obviously
$(id).datepicker();
work but it does not form that date the way I like it " yyyy/mm/dd
回答1:
For formatting use:
$("#your_ID").datepicker({dateFormat: "yyyy/mm/dd"});
For getting value of date use this:
var date = $("#your_ID").datepicker({ dateFormat: 'yyyy/mm/dd' }).val();
回答2:
When you init it, you pass an option object :
$(id).datepicker({dateFormat: "yyyy/mm/dd"});
回答3:
$(id).datepicker({dateFormat: **value**});
Fill value with one of this :
- Default, shows mm/dd/yy
- ISO 8601, shows yy-mm-dd
- Short, shows d M, y
- Medium, shows d MM, y
- Full, shows DD, d MM, yy
来源:https://stackoverflow.com/questions/16449803/jquery-datepicker-defaulting-to-yyyy-mm-dd