javascriptbootstrap-4datepickerbootstrap-datepicker

How to fix startDate of datepickerr is not working?


<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 4 DatePicker</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script src="https://unpkg.com/gijgo@1.9.13/js/gijgo.min.js" type="text/javascript"></script>
    <link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <input id="datepicker" width="276" />
    <script>
        $('#datepicker').datepicker({
             startDate: '+2d'
        });
    </script>
</body>
</html>

I want to use satrtDate functionality but I don't want to change the CDN link. How can I do this?


Solution

  • So, you want to select your date from after two days. Here is your solution

    $("#datepicker").datepicker({
         minDate: function () {
             var date = new Date();
             date.setDate(date.getDate() + 2);
             return new Date(date.getFullYear(), date.getMonth(), 
             date.getDate());
         },
    });