3

I am using Date Range Picker jQuery. I need to change start, end and title date format. Here is what I tried so far.

$('#from-todate').daterangepicker({
    ranges: {
    "setDate": new Date(),
    'Today': [moment(), moment()],
    'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
    'Last 7 Days': [moment().subtract(6, 'days'), moment()],
    'Last 30 Days': [moment().subtract(29, 'days'), moment()],
    'This Month': [moment().startOf('month'), moment().endOf('month')],
    'Last 6 Month': [moment().subtract(6, 'month').startOf('month'), moment().subtract(6, 'month').endOf('month')],
    'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
            "alwaysShowCalendars": true,
            "opens": "left",
            "applyClass": "btn-primary",
            "cancelClass": "hide-btn",
            "startDate": monthStartDate,
            "endDate": todaysdate,
            "maxDate": todaysdate,

}, function (start, end, label) {

    SetDates(start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'));
    console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
});
nextt1
  • 3,858
  • 2
  • 18
  • 26
Mitul Patel
  • 154
  • 1
  • 10

1 Answers1

6

Set locale property..try this:

$('#from-todate').daterangepicker(
{
    locale: {
      format: 'YYYY-MM-DD'
    },
    ..... // other properties       

}, 
function(start, end, label) {
   // code
});
Dhara Parmar
  • 8,021
  • 1
  • 16
  • 27