我的视图模型中有一个属性,如下所示:
[Editable(false)]
[Display(Name = "Date")]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public DateTime MovementDate { get; set; }
然而标记
<td>
@Html.DisplayFor(modelItem => item.MovementDate)
</td>
将日期值呈现为2013/05/15 12:00:00 AM
。
我究竟做错了什么?我的模型:
public class WithDateModel
{
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}")]
public DateTime TheDate { get; set; }
public WithDateModel()
{
TheDate = DateTime.Now;
}
}
我的观点:
@model ParkPay.WebTests.Models.WithDateModel
@Html.DisplayFor(m => m.TheDate)
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
渲染的内容:
2013/05/25 02:23:37 AM