How to manipulate datetime
and show in view in the following format?
HH:MM dd/MM/aaaa
How to manipulate datetime
and show in view in the following format?
HH:MM dd/MM/aaaa
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
.
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.
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.