Skip to content
Loading
  • Salman Beg
    0
    You need to change the format of bootstrap datepicker. Follow up with this link and change your format, https://bootstrap-datepicker.readthedocs.io/en/latest/
    0
  • Sanwar Ranwa
    0
    Hi Gcobani 
     
    You can format date according to your requirements 
     
    1. $('.datepicker').datepicker({  
    2.     format: 'mm/dd/yyyy',  
    3.      
    4. });  
    https://bootstrap-datepicker.readthedocs.io/en/latest/ 
    0
  • Sandhiya Priya
    0

    the issue is that you’re mixing up jQuery UI Datepicker options with Bootstrap Datepicker options.

    Bootstrap Datepicker does not use dateFormat. Instead, it uses the option format. That’s why your code is showing 01/08/2020 instead of 08/01/2020.

    Here’s how you can fix it:

    HTML / XML
      
        
          
          To
          
        
    
    
    
    $(document).ready(function() {
      var year = (new Date).getFullYear();
      $('.input-daterange').datepicker({
        format: "dd/mm/yyyy",   //  Correct option for Bootstrap Datepicker
        autoclose: true,
        startDate: new Date(year, 0, 1),   //  use startDate instead of minDate
        endDate: new Date(year, 11, 31)    //  use endDate instead of maxDate
      });
    });

    Key Fixes:

    • Use format: "dd/mm/yyyy" instead of dateFormat.

    • Use startDate and endDate instead of minDate and maxDate (those are jQuery UI options).

    • Ensure your placeholders match the format you expect (dd/mm/yyyy).

    Now when you select January 8, 2020, it will correctly show 08/01/2020.

    0