I have a Constants class file in my solution that is used for roles and messages and I need to create one for date formatting. Currently on several views, I have the date formatted as
<div><div class="card-body"><h4 class="card-title"><a class="forum-orange"
style="text-decoration:underline"
asp-action="Packet"
asp-controller="Home"
asp-route-packetId="@Model.PacketId">
Meeting:
@Model.Title</a></h4><div class="card-text">
Meeting date: <b> @Model.MeetingDateTime.ToString("dddd, MMMM dd yyyy h:mm tt")</b></div><div class="card-text">
Meeting time:<b> @Model.MeetingDateTime.ToString("hh:mm tt") </b></div><p class="card-text"><h6 class="forum-orange">
Voting has expired on<br/> @Model.CODateTime.ToString("dddd, MMMM dd yyyy h:mm tt")</h6></p></div></div>
I added this to my constants class:
public static class FormatDate { public const string DEFAULT_DATE_FORMAT = "dddd, MMMM dd yyyy h:mm tt"; }
And this updated the view:
<div><div class="card-body"><h4 class="card-title"><a class="forum-orange" style="text-decoration:underline" asp-action="Packet" asp-controller="Home" asp-route-packetId="@Model.PacketId"> Meeting: @Model.Title</a></h4><div class="card-text"> Meeting date: <b> @Model.MeetingDateTime.ToString(Constants.FormatDate.DEFAULT_DATE_FORMAT)</b></div><div class="card-text"> Meeting time:<b> @Model.MeetingDateTime.ToString("hh:mm tt") </b></div><p class="card-text"><h6 class="forum-orange"> Voting has expired on<br/> @Model.CODateTime.ToString(Constants.FormatDate.DEFAULT_DATE_FORMAT)</h6></p></div></div>
Would this be correct?