MVC Razor Dates

How many ways can we format a date...

 
If it is already a Date or DateTime type

            @item.ContributedDate.ToShortDateString()

       
    If is is a Nullable Date or DateTime type
  
                @if (item.ExpirationDate != null)
                {
                    @item.ExpirationDate.Value.ToString("d")
                }

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax