在Asp.NET MVC DD / MM / YYYY格式显示日期时间值 [英] Display DateTime value in dd/mm/yyyy format in Asp.NET MVC
问题描述
是否有可能显示的 DD / MM / YYYY 的帮助下格式 HTML赫普勒一个
在的DateTime
价值 Asp.NET MVC
的方法呢?我试图通过使用 @ Html.LabelFor
一些格式和增加了一些注解的相关属性像下面这样做,但它没有任何意义。任何帮助解决这一问题将是AP preciated。
型号:
[数据类型(DataType.Date)
[DisplayFormat(DataFormatString ={0:DD / MM / YYYY},ApplyFormatInEditMode = TRUE)]
公众可空<&System.DateTime的GT; RegistrationDate {搞定;组; }
所有你需要做的就是在HTML辅助你想要的类型格式。即
@ Html.TextBoxFor(M = GT; m.ResgistrationhaseDate,{0:DD / MM / YYYY})
和你不需要提供日期格式模型类..它会很好地工作。
Is it possible to display a DateTime
value in dd/mm/yyyy format with the help of HTML Hepler
methods in Asp.NET MVC
? I tried to do this by using some formats in @Html.LabelFor
and adding some annotations to the related property like below but it does not make any sense. Any help to solve this problem would be appreciated.
Model:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> RegistrationDate { get; set; }
All you have to do is type format you want in html helper. ie.
@Html.TextBoxFor(m => m.ResgistrationhaseDate, "{0:dd/MM/yyyy}")
and you don't need to provide date format in model class.. it will work perfectly..
这篇关于在Asp.NET MVC DD / MM / YYYY格式显示日期时间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!