I have a datetime picker, but it only allow me to pick the date and not the time. Is there a way to put the time selection?
Model
[Display(Name = "Start")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy HH:mm}", ApplyFormatInEditMode = true)]
public DateTime BookingStartDate { get; set; }
View:
<input asp-for="BookingStartDate" min="@DateTime.Now.ToString("dd/MM/yyyy HH:mm")" asp-format="{0:dd/MM/yyyy HH:mm}" class="form-control" />
Since you're using the asp-for
tag helper, you can change the [DataType(DataType.Date)]
attribute of BookingStartDate to [DataType(DataType.DateTime)]
and the page should render the input tag with date and time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.