Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 476.2k

How to create a correct date format in bootstrap date-picker

Jan 9 2020 2:00 AM
Hi Team
 
I want to create this format on bootstrap date-picker.e.g 08/01/2020. Mine show this format on the form,eg. 01/08/2020(which is not correct from the form when date is selected) Here is my code for this logic.
  1. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker3.min.css">  
  2. <script type='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.min.js"></script>  
  3. <!---DatePicker for startDate and endDate. ---->  
  4. <div class="d-flex justify-content-start">  
  5. <div class = "col-xl-10.5 col-lg-10.5 col-md-10 col-sm-10.5 col-10.5">  
  6. <div class="input-daterange input-group" id="datepicker">  
  7. <input type="text" class="input-sm form-control" name="from" placeholder="startdate"/>  
  8. <span class="input-group-addon">To</span>  
  9. <input type="text" class"input-sm form-control" placeholder="enddate"/> </div> </div> </div><br>  
  10. // date functionality  
  11. $(document).ready(function()  
  12. {  
  13. var year = (new Date).getFullYear();  
  14. $('.input-daterange').datepicker({ dateFormat: "dd-mm-yy", autoclose:true, minDate: new Date(year, 0, 1), maxDate:new Date(year, 11, 31) });  
  15. });  

Answers (3)