not able to format date using jquery datepicker

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 14:14:22

问题


I am invoking the datepicker on an input box. However, irrespective of the format I am giving, it always returns the date in mm/dd/yyyy format. I want it to return - 30-11-2011 (dd-mm-yyyy) format. Below are the options I tried -

Option 1

$("#birthdate").datepicker({
    changeYear: true,
    changeMonth: true
    dateFormat: 'yy-mm-dd'
    });

Option 2

$.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26));

My html includes jquery-ui.js, jquery-ui-datepicker.js and jquery.js.

I have already referred to jQuery UI DatePicker - Change Date Format and Jquery datepicker format date not working and tried all the option but none of them in working for me. Please let me know if someone knows the solution.


回答1:


This was my comment, but posting as the answer as the OP said it was the solution:

You are loading jquery-ui AND jquery-ui-datepicker? I use this widget a lot and have not had trouble with date formatting. It's possible that including both of these files is what is at fault?



来源:https://stackoverflow.com/questions/12828720/not-able-to-format-date-using-jquery-datepicker

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