JQuery Mobile UI DatePicker Change Date Format

╄→гoц情女王★ 提交于 2019-12-24 06:01:09

问题


I am trying to change the date format in the JQM UI Datepicker.

It's got an input which display's the dates as you change them.

I need it to display in dd/mm/yyyy format.

Can anyone help please?

UPDATE:

I'm trying this, but nothing's changing:

<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>

回答1:


Try this $.datepicker.formatDate('dd/mm/yyyy');

More reference here




回答2:


Change the "jquery.ui.datepicker.mobile.js" file

add date format: dateFormat: "dd/mm/yy" Code shown below

//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" }));
        }); 
    });


来源:https://stackoverflow.com/questions/6106970/jquery-mobile-ui-datepicker-change-date-format

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