Reputation: 28783
I have the following code: <%= Html.Encode(String.Format("{0:g}", item.startDate)) %>
It outputs something like 01/01/2011 00:00 but I would to ONLY show the date and not the time! How can I do this? Thanks
Upvotes: 1
Views: 2137
Reputation: 93424
<%= item.startDate.ToShortDate() %>
The above will take into account the current Locale and format it as the locale dictates. There is also no point in using Html.Encode()
since it's impossible for the output of the date function to contain anything dangerous that needs encoding.
Upvotes: 4
Reputation: 35477
<%= Html.Encode(item.StartDate.ToString("dd/MM/yyy")) %>
Upvotes: 1