DateTime field display in View without part of Hours

5

With the code below I'm retrieving the DateTime with the time beyond the date, which I do not like.

cursos.Data = DateTime.Parse(collection["Data"]);

I tried to format using the substring within DateTime.Parse, but I did not succeed.

My domain

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime Data { get; set; }

In the client's CMS in edit mode, it is showing on 8/30/2014 00:00:00, even though the bank has the correct date, ie no time

    
asked by anonymous 01.08.2014 / 14:41

1 answer

3

This problem is very common when there is manipulation of DateTime in Views . The best way to resolve this is by using the following:

@Html.TextBoxFor(model => model.Data, "{0:dd/MM/yyyy}", new { @class = "meuCampoDate" })

See also:

link

    
01.08.2014 / 23:44