Set Default Date Bootstrap Datepicker

前端 未结 9 1278
暗喜
暗喜 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 14:46

    This works for me after a long hours of search , This solution is for Bootstrap datetimepicker version 4. when you have to set the default date in input field.

    HTML

    "input type='text' class="form-control" id='datetimepicker5' placeholder="Select to date" value=''// $myDate is having value '2016-02-23' "
    

    Note - If You are coding in php then you can set the value of the input datefield using php, but datetimepicker sets it back to current date when you apply datetimepicker() function to it. So in order to prevent it, use the given JS code

    JAVASCRIPT

    
    

提交回复
热议问题