ASP.Net MVC jQuery UI DatePicker Date Format

后端 未结 2 2118
刺人心
刺人心 2020-12-18 12:42

I\'m at my wits end trying to force this jQuery datepicker control to understand specific date formats. What the hell is going on here?

View

@Html.Te         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 13:00

    You need to set it like this:

    $(function () {
        $(".datefield").datepicker({
            dateFormat: 'dd/mm/yy',
            showOn: "button"
        });
    });
    

    As noted in the documentation, the yy format specifies a 4 digit year. When you write yyyy you are basically telling it to render the year twice. Relating to the month, jQuery associates MM (capital letters) with the name of the month and mm with the corresponding digit form.

    In conclusion, the date formats differ between .Net and jQueryUI.

提交回复
热议问题