简体   繁体   中英

How to preselect date in bootstrap 3 datetimepicker

I am using Bootstrap 3 Datepicker for that I am trying following

<div class='input-group date datetimepicker1'>
     <input type='text' name="actEndDate" placeholder="End Date"  class="form-control" required/>
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
    </span>
</div>

and calling it by following

 $(".datetimepicker1").datetimepicker();

Its working fine

now i am changing date using JavaScript on clicking of other field i have date formate like 11/4/2015 and for that i am trying following

   $('.datetimepicker1').datetimepicker({
        defaultDate: "11/1/2013"

    });

now how to preselect date ?

Note : its different from jquery datepicker

I see this way for your question:

<script type="text/javascript">
            $(function () {
                $('#datetimepicker5').datetimepicker({
                    defaultDate: "11/1/2013",
                    disabledDates: [
                        moment("10/2/2013"),
                        new Date(2013, 11 - 1, 21),
                        "11/22/2013 00:53"
                    ]
                });
            });
        </script>

you can see this page for other doubt.

Setting defaultDate parameter is the right method to resolve it.

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