Documentation v1.0.4

Preview Purchase

Overview

Date Range Picker can be attached to any webpage element to pop up two calendars for selecting dates, times, or predefined ranges like "Last 30 Days". For full documentation please check the plugin's site.

Usage

Date Range Picker's CSS and Javascript files are bundled in the global plugin bundles and globally included in all pages:
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css"/>
<script src="assets/plugins/global/plugins.bundle.js"></script>

Initialization

  • Date Range Picker's CSS is highly customized in sass/vendors/plugins/_daterangepicker.scssSCSS file in order to use it as native component within the design system. The SCSS code is compiled into assets/plugins/global/plugins.bundle.cssand globally included in all pages.
  • Date Range Picker's Javascript is bundled with assets/plugins/global/plugins.bundle.jsand globally included in all pages.

Basic Examples

Basic example of Date Range Picker attached to an input element:
$("#kt_daterangepicker_1").daterangepicker();
<div class="mb-0">
    <label class="form-label">Basic example</label>
    <input class="form-control form-control-solid" placeholder="Pick date rage" id="kt_daterangepicker_1"/>
</div>

With Times

Enable date selection with times:
$("#kt_daterangepicker_2").daterangepicker({
    timePicker: true,
    startDate: moment().startOf("hour"),
    endDate: moment().startOf("hour").add(32, "hour"),
    locale: {
        format: "M/DD hh:mm A"
    }
});
<div class="mb-0">
    <label class="form-label">Example</label>
    <input class="form-control form-control-solid" placeholder="Pick date rage" id="kt_daterangepicker_2"/>
</div>

Single Date Picker

Use Date Range Picker as single date picker:
$("#kt_daterangepicker_3").daterangepicker({
        singleDatePicker: true,
        showDropdowns: true,
        minYear: 1901,
        maxYear: parseInt(moment().format("YYYY"),10)
    }, function(start, end, label) {
        var years = moment().diff(start, "years");
        alert("You are " + years + " years old!");
    }
);
<div class="mb-0">
    <label class="form-label">Example</label>
    <input class="form-control form-control-solid" placeholder="Pick date rage" id="kt_daterangepicker_3"/>
</div>

Predefined Date Ranges

Enable date range selection from predefined options:
var start = moment().subtract(29, "days");
var end = moment();

function cb(start, end) {
    $("#kt_daterangepicker_4").html(start.format("MMMM D, YYYY") + " - " + end.format("MMMM D, YYYY"));
}

$("#kt_daterangepicker_4").daterangepicker({
    startDate: start,
    endDate: end,
    ranges: {
    "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 Month": [moment().subtract(1, "month").startOf("month"), moment().subtract(1, "month").endOf("month")]
    }
}, cb);

cb(start, end);
<input class="form-control form-control-solid" placeholder="Pick date rage" id="kt_daterangepicker_4"/>

Modal Example

Use Date Range Picker within Bootstrap Modal:
$("#kt_daterangepicker_5").daterangepicker();
<!--begin::Modal-->
<div class="modal fade" tabindex="-1" id="kt_modal_1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Modal title</h5>

                <!--begin::Close-->
                <div class="btn btn-icon btn-sm btn-active-light-primary ms-2" data-bs-dismiss="modal" aria-label="Close">
                    <span class="svg-icon svg-icon-2x"></span>
                </div>
                <!--end::Close-->
            </div>

            <div class="modal-body">
                <div class="mb-0">
                    <label for="" class="form-label">Select date</label>
                    <input class="form-control form-control-solid" placeholder="Pick date" id="kt_datepicker_10"/>
                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>
<!--end::Modal-->
Learn & Get Inspired

Support at devs.keenthemes.com

Join our developers community to find answer to your question and help others. FAQs
Get Support
Documentation
From guides and how-tos, to live demos and code examples to get started right away.
Plugins & Components
Check out our 300+ in-house components and customized 3rd-party plugins.
Layout Builder
Build your layout, preview it and export the HTML for server side integration.
What's New
Latest features and improvements added with our users feedback in mind.
Buy now