使用MVC3 DateTime对象,我有正确显示日期的问题.
在控制器中,我设置Date = DateTime.Now.
在viewmodel中:
[required(ErrorMessage = "Please enter a date")] [DisplayFormat(ApplyFormatInEditMode = true,DataFormatString = "{0:dd.mm.yyyy}")] public DateTime Date { get; set; }@H_404_7@在视图中:
@Html.LabelFor(m => Model.Date,"Date") @Html.ValidationMessageFor(m => Model.Date) @Html.TextBoxFor(m => Model.DatoForIntervju,new { @class = "datepicker" })@H_404_7@输出:
<input class="datepicker" (...) value="26.09.2011 13:26:16" />@H_404_7@但是,我想要的值是26.09.11.
为什么不起作用?