jQuery datepicker() - defaulting to yyyy/mm/dd

馋奶兔 提交于 2019-12-25 02:06:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!