Datetime field display in View with hours, minutes, day/month/year?

Asked

Viewed 1,378 times

1

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

HH:MM dd/MM/aaaa
  • You want to display in this format using an input or just display as text?

  • Using an input

  • Is using Razor ?

3 answers

1

Without you using it jQuery you can use the plugin Datetimepicker.

Just read the documentation and apply to the fields you want this format.

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

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

and so on javascript:

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

for this to work you must use the files JS and CSS plugin in conjunction with the jQuery.

  • in this format: Tostring("HH:mm dd/MM/yyyy") soh shows me the date and Time Reset.

  • You checked if the date is with the values of hours and minutes in the database?

1

1

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.