jQueryUI.DatePicker如何以dd / mm / yyyy格式更改日期?

时间:2016-01-05 05:59:54

标签: jquery-ui datepicker

jQueryUI.DatePicker如何将日期格式mm/dd/yyyy更改为dd/mm/yyyy
我如何使用Data-Picker以格式dd/mm/yyyy格式化日期? 我使用$(".selector").datepicker({ dateFormat: 'dd/mm/yy' })但不起作用。

我添加了这些链接;

<script src="date/jquery.js"></script>
<link href="date/jquery-ui.min.css" rel="stylesheet" />
<script src="date/jquery-ui.min.js"></script>
<link href="date/jquery-ui.min.css" rel="stylesheet" />

脚本:

<script>
    $(function () {
      $(".date").datepicker({
          dateFormat: 'mm-dd-yy',
          changeMonth: true,
          changeYear: true
       });
     });
</script>

<asp:TextBox ID="txtStartDate" runat="server" 
  SkinID = "txtboxCustomizedMSkin" AutoPostBack = "True" OnTextChanged 
  = "txtStartDate_TextChanged" placeholder="DD-MM-YYYY" CssClass="date">
</asp:TextBox>

1 个答案:

答案 0 :(得分:2)

只需将dateFormat选项更改为dd/mm/yy,请注意yy代表4位数年份

&#13;
&#13;
$(function() {
  $(".date").datepicker({
    dateFormat: 'dd/mm/yy',
    changeMonth: true,
    changeYear: true
  });
});
&#13;
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>

<input id="txtStartDate" class="date" placeholder="DD-MM-YYYY" />
&#13;
&#13;
&#13;