JQuery Mobile UI DatePicker Change Date Format

JQuery Mobile UI DatePicker Change Date Format

本文关键字:Date Format Change DatePicker Mobile UI JQuery      更新时间:2023-09-26

我正在尝试更改 JQM UI 日期选择器中的日期格式。

它有一个输入,在您更改日期时显示日期。

我需要它以 dd/mm/yyyy 格式显示。

谁能帮忙?

更新:

我正在尝试这个,但没有任何变化:

<script>
  //reset type=date inputs to text
  $( document ).bind( "mobileinit", function(){
    $.mobile.page.prototype.options.degradeInputs.date = true;
  });   
</script>
<script language="javascript">
    $(document).ready(function() {
        $.datepicker.formatDate('dd/mm/yyyy'); //ADDED HERE
        $("input[type='submit']").click(function(e) {
            e.preventDefault();
        });
    });
</script>

试试这个$.datepicker.formatDate('dd/mm/yyyy');

更多参考在这里

更改"jquery.ui.datepicker.mobile.js"文件

添加日期格式

:日期格式:"日/月/年"代码如下所示

//bind to pagecreate to automatically enhance date inputs   
    $( ".ui-page" ).live( "pagecreate", function(){     
        $( "input[type='date'], input[data-type='date']" ).each(function(){
            $(this).after($("<div />").datepicker({ altField: "#" + $(this).attr("id"), showOtherMonths: true, dateFormat: "dd/mm/yy" }));
        }); 
    });