Link to home
Start Free TrialLog in
Avatar of nightshadz
nightshadzFlag for United States of America

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>

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

maybe bootstrap datepicker?
Avatar of nightshadz

ASKER

This is just a date picker though. I'm looking for a date and time picker. similar to datetime-local.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>

Open in new window

Exactly what I was looking for. Thank you!