Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date range picker default value

Hi all I'm using daterangepicker.jQuery.js

( http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/6.0.0/vtiger6/libraries/jquery/jquery-ui/third-party/jQuery-UI-Date-Range-Picker/js/daterangepicker.jQuery.js?rev=13838 )

per default it's initialized at 1970-01-01 and i've searched in the whole javascript but i didn't find it does someone know how to change this value ? and if possible how to limit the calendar in today's date please

( EDIT )

I've tried

<script type="text/javascript">
            $(function(){
                    $('#rangeBa, #rangeBb').daterangepicker();
             });
             $(document).ready(function(){
                var date = '17-05-2013';
                $('#rangeBa, #rangeBb').daterangepicker('setDate', date);?
            })
        </script>

but it's not working

like image 457
Kirk ERW Avatar asked Oct 29 '25 12:10

Kirk ERW


1 Answers

This works like a charm. You can try it.

var today = new Date();
var endDate = new Date();
endDate.setMonth(endDate.getMonth() + 1);
$('#rangeBa, #rangeBb').daterangepicker({ 
    startDate: today, // after open picker you'll see this dates as picked
    endDate: endDate,
    locale: {
       format: 'DD-MM-YYYY',
    }
}, function (start, end, label) {
    //what to do after change
}).val(today + " - " + endDate); //set it to see it inside input (don't forget to format dates)

If you want to limit date range just use minDate and maxDate options.

like image 147
Filip Kováč Avatar answered Nov 01 '25 00:11

Filip Kováč



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!