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 - Reset the Admin Password via SQL Server

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

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version