0
我在数据库中的字符串字段TimeAdd,我计算使用下延:申请时间格式化字符串场模型MVC
public static string ToIso8601Date(this DateTime dateTime)
{
DateTimeOffset dateOffset = new DateTimeOffset(dateTime, TimeZoneInfo.Local.GetUtcOffset(dateTime));
return dateOffset.ToString("o");
}
// here is its result: 2013-04-01T16:16:17.7646200+03:00
这里是我的模型字段:
和View( )部分:
<td>
@Html.DisplayFor(modelItem => item.TimeAdd)
</td>
我不存在我的目标。如何纠正使用DataFormatString?在我的输出中没有任何改变。
编辑
Ok.I不想浪费我的时间,所以我接下来做的事:
,你的DataFormatStringpublic string TimeAdd
{
get
{
return _timeAdd.Substring(0, 16).Replace("-", " ").Replace("T", " ") ;
}
set
{
_timeAdd = value;
}
}
你试过'@“{dd/MM/yyyy HH:mm}”'? –