In this article you will learn about how to display a DateTime value in dd/MMM/yyyy format by means of HTML Hepler methods in Asp.NET MVC.
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime PostedOn
{
get{
return mPostedOn;}
set
{
mPostedOn = value;}
}
@Html.DisplayFor(m=> m.PostedOn, "{dd/MMM/yyyy}")
Output:
25-Feb-2016