我在 mvc4 应用程序中使用 twitter boostrap datepicker。在我的模型中,我将日期属性设置为-
[DisplayName("Date Last Modified")]
[DisplayFormat(DataFormatString = "{0:dd/MMM/yyyy}")]
public DateTime? EmpLastModified { get; set; }
Jquery datepicker 是-
@if (Model.HasValue && ((DateTime)Model.Value).Year > 1500)
{
@Html.TextBox("", String.Format("{0:dd/MMM/yyyy }", Model.Value), new { @class = "textbox", @style = "width:125px;" })
}
else {
@Html.TextBox("", String.Format("{0:dd/MMM/yyyy}", DateTime.Now), new { @class = "textbox", @style = "width:125px;" })
}
<script type="text/javascript">
$(document).ready(function () {
$("#@id").datepicker
({
dateFormat: '0:dd/MMM/yyyy',
showStatus: true,
showWeeks: true,
highlightWeek: true,
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
showAnim: "scale",
showOptions: {
origin: ["top", "left"]
}
});
});
日期选择器应显示 23-May-2013 作为日期,但它显示 11/23/2013 而在萤火虫中显示
<input id="EmpDateAdded" class="textbox" type="text" value="23-May-2013" style="width:125px;" name="EmpDateAdded" data-val-date="The field Date Added To System must be a date." data-val="true">
我使用 datepicker.css 和 bootstrap-datepicker.js, date.format.js
请帮忙。提前致谢