为什么 jquery 日期选择器会更改几个月的天数

本文关键字:几个月 jquery 日期 选择器 为什么 | 更新日期: 2023-09-27 18:34:33

我正在做MVC项目,使用jquery日期选择器我在帖子中遇到了问题。我使用包含文本框和jquery函数的部分视图。喜欢这个:

 @model Nullable<System.DateTime>
<div class="row-fluid input-append">
    @if (Model.HasValue && Model.Value != DateTime.MinValue)
    {
        @Html.TextBox("", String.Format("{0:dd/MM/yyyy}", Model.Value), new { @class = "input-small date-picker",@readonly = true, style = "cursor:pointer; background-color: #FFFFFF; text-align: center;" })
    }
    else
    {
        @Html.TextBox("", String.Format("{0:dd/MM/yyyy}", ""), new { @class = "input-small date-picker", @readonly = true, style = "cursor:pointer; background-color: #FFFFFF; text-align: center;" })
    }
</div>
@{
    string name = ViewData.TemplateInfo.HtmlFieldPrefix;
    string id = name.Replace(".", "_");
}
<script type="text/javascript">
    $('#@id').datepicker({
        dateFormat: 'dd/mm/yy',
        todayHighlight: true,
        clearBtn: true,
        forceParse: true,
        autoclose: true,
    });
</script>

当我格式化日期选择器以天/月/年为单位选择日期时,当我选择日期格式时,就可以了!我的意思是,我在日历中选择 8 月 5 日,文本框显示 05/08/2013,但是单击保存时会出现问题,因为在控制器中,日期的值更改为几天到几个月!谢谢!

为什么 jquery 日期选择器会更改几个月的天数

web.config中添加以下内容:

<system.web>
    <globalization culture="en-GB" uiCulture="en-GB" />
</system.web>

它应该更改默认日期解析。