Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
想知道是否有某种方法可以使用@Html.DisplayFor() 显示月、日和年。我有一个日期,例如 2013 年 3 月 10 日,但需要在可打印的表格上分别显示每个月的日和年。
在您的视图模型标记日期字段中,具有以下属性:
[DisplayFormat(DataFormatString = "{0:MMMM dddd yyyy}")] DateTime MyDateField
您可以设置任何所需的日期格式