0
I have a public string TimeUpdate { get; set; }
in my model that is of the form "13-12-2016 17:12:09"
.I need that in the view it appears only the hours and the minutes, as I can do the field treatment?
PS: I have tried [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:t}")]
but without success. I thank you in advance.
@Gypsy omorrisonmendez will this is duplicate if the field is
String
and there the field is aDateTime
, there are differences, there is no such conversion?– novic
Good,
[DisplayFormat]
does not work in this case. It must have converted aDateTime
standard forstring
if it is in Model. I might even vote to reopen.– Leonel Sanches da Silva
My concern was whether or not to be duplicate, because, the data are different and to
DateTime
would be a duplicate, butString
no, by conversion. @Ciganomorrisonmendez– novic
All right. It’s reopened. I’m not answering. Just link the answer I gave to the other: http://answall.com/questions/162550/formata%C3%A7%C3%a3o-de-exibi%C3%A7%C3%a3o-de-data-displayfor? noredirect=1&lq=1
– Leonel Sanches da Silva
@Mario because you use it like this:
public string TimeUpdate { get; set; }
??? you made some additional code?– novic
I didn’t want to explain how I get this information so as not to prolong the question, but it’s the following: This is a model of a REST request and the returned Json is a field of type "timeUpdate": "14-12-2016 10:15:34". I already tried to change the type to Datetime only that I get
01/01/0001 00:00:00
then I don’t know how to treat it... =/– Mário
@Mario your problem then is before this question, which is to transform a
JSON
an object. If I were you would create a new question of how to receive aREST
which has a date in this format "13-12-2016 17:12:09" with Json.NET and then use the solution made by the Gypsy in that link would be better, because, I could even propose a solution in this class but, could be considered a gambiarra– novic