Umbraco Razor: Check to see Whether the Date Field is Filled in and Only Display time if the Time is filled in.

Umbraco Razor: Check to see Whether the Date Field is Filled in and Only Display time if the Time is filled in.   

and

Formating the Time in Umbraco using Razor



<p>Event Date: @Model.eventDate.ToString("dd MMMM yyyy")</p>

<!-- If the start time is filled in then write it out -->
@if(@Model.eventDate.ToString("H:mm") != "0:00")
{
<p>Start Time: @Model.eventDate.ToString("H:mm")</p>
}




<!-- If the End date is filled in write it out -->
@if (Model.endDate.ToString() != "")
{
<p>End Date: @Model.endDate.ToString("dd MMMM yyyy")</p>

}





<!-- If the end time is filled in then write it out -->
@if(@Model.endDate.ToString("H:mm") != "0:00" && Model.endDate.ToString() != "")
{
<p>End Time: @Model.endDate.ToString("H:mm")</p>
}

Comments

Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco