Display DateTime field in View with hours, minutes, day / month / year?

1

How to manipulate datetime and show in view in the following format?

HH:MM dd/MM/aaaa
    
asked by anonymous 18.03.2015 / 14:37

3 answers

1

Without you using jQuery you can use the DateTimePicker plugin.

Just read the documentation and apply it to the fields you want.

An example would be to do something like this in HTML :

<input class="datetimepicker" type="text"/>

and thus not javascript :

$('.datetimepicker').datetimepicker();

For this to work you should use the JS and CSS files of the plugin together with jQuery .

    
18.03.2015 / 14:52
1

No Controller

ViewData['MinhaDataMinhaVida'] = DateTime.Now;

In View

<input type='text' value='<%=ViewData['MinhaDataMinhaVida'].ToString("HH:mm dd/MM/yyyy") %>'> </input>

I did not test, but I think it is correct.

link

    
18.03.2015 / 14:55
1

If you're using Razor, you can use @Html.TextBoxFor() specifying a format of date :

@Html.TextBoxFor(model => model.MinhaData, "hh:mm dd/MM/yyyy", new { @class = "form-control" })

Note: the class "form-control" is from Bootstrap 3.

    
17.04.2015 / 17:35