我有这个model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
namespace PrototypeHelp.Models
{
public class DocumentModel
{
public int documentID { get; set; }
public String Title { get; set; }
public DateTime DateCreated { get; set; }
public String Description { get; set; }
public int authorID { get; set; }
public String AuthorName { get; set; }
public int categoryID { get; set; }
public String Category { get; set; }
public int topicID { get; set; }
public String Topic { get; set; }
[AllowHtml]
public String DocumentBody { get; set; }
}
}
我想只显示日期使用jquery
,但我不能摆脱在"DateCreated“。
有谁可以帮我?我正在使用jquery
显示它
发布于 2013-09-03 10:01:23
在日期的模型定义中使用此参数
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
发布于 2013-09-03 10:08:54
若要显示日期,可以使用DisplayFormat属性装饰该属性。该值是您想要显示日期的格式。
例如
public class DocumentModel
{
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}")]
public DateTime DateCreated { get; set; }
...
}
或者,在视图中,您可以在ToString()
函数中指定格式。
@Model.DateCreated.ToString("yyyy/MM/dd")
https://stackoverflow.com/questions/18589270
复制