Search code examples
daterangepicker

Issue with Daterangepicker


I'm using the daterangepicker from https://sensortower.github.io/daterangepicker/docs#configuration

$(".daterangepicker-field").daterangepicker({
  startDate:moment(),
  endDate:moment(),
  timeZone:'Europe/Bucharest',
  forceUpdate: true,
  orientation:'left',
  ranges:{},
  periods: ['day','week','month','year'],
  expanded:true,
  firstDayOfWeek: 0, 
  minDate:'2019-01-01',
  callback: function(startDate, endDate, period){
    var title = startDate.format('MMM D, YYYY') + ' – ' + endDate.format('MMM D, YYYY');
    $(this).val(title);
  }
    });

The problem is, if I set the firstDayOfWeek: 1 (Monday), the calendar will change the label from Sunday to Monday, but in fact the days in the calendar will remain the same - so the calendar is wrong. enter image description here

Can you help me figure out what is causing this?

Thanks!


Solution

  • I finally solve it, in case someone else needs it. The issue was related to moment.js. I used the documentation found here: https://momentjs.com/docs/#/customization/dow-doy/ with the following code:

        moment.updateLocale("en", { week: {
      dow: 1, // First day of week is Monday
    }});