MVC4 日期格式化

// MVC返回到View的日期一般都会带有0分0秒,比如2014/08/22 在前端显示为2014/08/22 00:00:00,比较不美观


// 如果是想展示数据 用label @Html.Label("RegularTime", String.Format("{0:d}", Model.RegularTime)) //如果需是个日期控件,用textbox @Html.TextBox("CalendarBirthdate", String.Format("{0:d}", Model.CalendarBirthdate), new { id = "_txtCalendarBirthdate", onclick = "WdatePicker()", @class = "input_style" })
<br>// 或者
<input type="text" id="_txtRegularTime" name="RegularTime" value="@String.Format("{0:d}", Model.RegularTime)" class="input_style" onclick="WdatePicker()" />

  

posted @ 2014-08-22 17:36  小丑不戴面具  阅读(302)  评论(0编辑  收藏  举报