2016-04-23 62 views
0

我正在使用Date Range Picker jQuery。我需要更改開始,結束和標題日期格式。 這是我到目前爲止所嘗試的。更改daterangepicker的日期格式

$('#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 + ')"); 
}); 
+1

嗨,這可能會幫助 - http://stackoverflow.com/a/32801191/4719761 – Bhumika107

回答

2

設置的地點property..try這樣的:

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

}, 
function(start, end, label) { 
    // code 
});