Set Default Date Bootstrap Datepicker

前端 未结 9 1275
暗喜
暗喜 2021-02-12 14:15

How to set a default date in Bootstrap Datepicker?

I want to set a date : 24/12/2006

When I open datepicker it should show me this date select on calender.

相关标签:
9条回答
  • 2021-02-12 15:07

    If you want to make the change global, look for the following in bootstrap-datepicker.js:

    function UTCToday(){
    var today = new Date();
    return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
    

    and hard code in your date, for example:

    function UTCToday(){
    var today = new Date();
    return UTCDate(2006, 00, 01);
    

    Which will open on 1 January 2006. Note that for some reason January is '00' rather than '01'.

    0 讨论(0)
  • 2021-02-12 15:10

    you can simply assign a value (with you to your input tag and it should work

    <input type="text" class="form-control" value="22-05-2017">
    
    0 讨论(0)
  • 2021-02-12 15:14

    In my version, if you put the val in the input, the calendar is updated automatically.

    $('#birthdate').val("01/01/2001");
    
    0 讨论(0)
提交回复
热议问题