【问题标题】:jQuery datepicker changes in date formatjQuery datepicker 更改日期格式
【发布时间】:2012-05-15 15:17:37
【问题描述】:

下面的代码对我不起作用。每当我尝试更改日期时,日期都会从 2012 年 15 月 5 日切换到 2012 年 5 月 15 日。

<script>
$(document).ready(function(){
    $("#date").datepicker({ 
    });
    var myDate = new Date();
    var month = myDate.getMonth() + 1;
    var prettyDate = myDate.getDate() + '/' + month + '/' + myDate.getFullYear();
    $("#date").val(prettyDate);
});
    </script>

【问题讨论】:

  • 听起来像是本地化问题。你在哪个国家?
  • 我在英国

标签: javascript ajax jquery-ui datepicker


【解决方案1】:

请在日期选择器构造函数中指定日期格式为“dd/m/yyyy”。

 var options = {
                dateFormat: "dd/m/yyyy"
            };
            $('#Item').datepicker(options);

【讨论】:

  • 我该怎么做?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多