Rather than using something like this for datatime values:
@Html.DisplayTextFor("", String.Format("{0:MM/dd/yyyy}", Model.DOB))
Is it possible to set the format globally (e.g. in the web.config) in asp.net mvc 3.0?
Create a DisplayTemplate at Views/Shared/DisplayTemplates/DateTime.cshtml
@model DateTime
@String.Format("{0:MM/dd/yyyy}", Model))
Whenever you use @Html.DisplayFor() with a DateTime property, MVC will use this template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With