'Bootstrap datepicker how to allow past 6 months dates

How can I enable past 6 months dates from today including today in Bootstrap datepicke.

For example if today is 4th October 2015 then calendar will only allow to pick any date between 4th April 2015 to 4th October 2015.

    var date = new Date();
    // initialize daterange
    $('.input-daterange').datepicker({
        format: "mm/dd/yy",
        orientation: "top left",
        autoclose: true,
        todayHighlight: false,
        toggleActive: false,
        startDate: date
    });


Solution 1:[1]

startDate should do it (doc)

Solution 2:[2]

I'm asuming you are using this, so you can make use of endDate and startDate.

You need to set the startDate to the Date.now - 6 months and the endDate to today.

var now = new Date();
var sixmonthsago = new Date(now.setMonth(now.getMonth() - 6));


$('.input-daterange').datepicker({
    format: "mm/dd/yy",
    orientation: "top left",
    autoclose: true,
    todayHighlight: false,
    toggleActive: false,
    endDate: now,
    startDate: sixmonthsago
});

I didint test the code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MBaas
Solution 2 prashmi