nightshadz
asked on
Need assistance with cross-browser compatible date-time picker (using ASP.NET Core 2 MVC)
Using ASP .NET Core 2 MVC, I have the following code in my .cshtml, but this datetime-local type is not cross browser compatible. I googled a few examples but can't seem to get them to work. Could someone direct me to or show me a good replacement example?
<div class="form-group">
<label asp-for="StartTime" class="control-label"></label>
<input type="datetime-local" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm").Replace(' ', 'T')" asp-for="StartTime" class="form-control">
<span asp-validation-for="StartTime" class="text-danger"></span>
</div>
maybe bootstrap datepicker?
ASKER
This is just a date picker though. I'm looking for a date and time picker. similar to datetime-local.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
working page :
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.js"></script>
<script>
jQuery(function($) {
$('.form-control.datetime').each(function() {
var startDate = $(this).data("initial-datetime");
$(this).datetimepicker({ });
});
});
</script>
</head>
<body>
<input type="text" class="form-control datetime" value="2018-07-09 10:18" asp-for="StartTime">
<input type="text" class="form-control datetime" value="2018-05-09 15:54" asp-for="EndTime">
</body>
</html>
ASKER
Exactly what I was looking for. Thank you!