简体   繁体   中英

Show datetime picker with time

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM