Search code examples
htmlcssbootstrap-4datetimepickerbootstrap-datetimepicker

Bootstrap 4 DateTimePicker start week on monday


In the Bootstrap 4 datetimepicker, how do I make the weeks start on Monday instead of Sunday?


Solution

  • As you commented, this does not appear to be true for this library

    You can do that in the options, while initiating your datepicker

    $('#yourElement').datetimepicker({
        weekStart: 1
    });
    

    This changes the first day of the week in your perspective.

    I thought I knew this library :) But this one does support weekStart and basically provides the same functionality.

    However, changing the locale does work and is the preferred way. These libraries work with moment.js.

    $('#yourElement').datetimepicker({
        locale: 'en' // or whatever your locale is, 'ru' for example
    });
    

    This works because whatever your locale's first DOW is, moment.js will alter that accordingly as explained here. You can use this method if you want to support other locales automatically.

    For example, you might be able to determine the client's locale and pass that directly into the datepicker:

        locale: navigator.language || 'en'
    

    Besides, you can find all the info on the page you included in your question :)