Hi ruben00000,
Input type datetime is not supported in modern browser.
For more detail about input type datetime, refer https://reference.codeproject.com/html/element/input/datetime.
So you need to make use of type as datetime-local.
Please check the below example.
Model
public class WorkOrder
{
public DateTime? ArrivalTime { get; set; }
}
Controller
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult Index(WorkOrder data)
{
ViewBag.ArrivalTime = data.ArrivalTime.HasValue ? data.ArrivalTime.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty;
return View();
}
}
View
@model Sample_729649.Models.WorkOrder
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
</head>
<body>
<form method="post" asp-controller="Home" asp-action="Index">
<input type="datetime-local" class="ArrivalTime form-control"
id="ArrivalTime" name="ArrivalTime" value="@ViewBag.ArrivalTime" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
Screenshots
The Form
Selected DateTime
For more details on datetime-local, please refer the below link.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local