not able to format date using jquery datepicker

2019-07-20 03:55发布

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条回答
Melony?
2楼-- · 2019-07-20 04:17

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?

查看更多
登录 后发表回答