Google trends Public Holidays Coupon Code Code Compiler

Bootstrap daterangepicker example using daterangepicker plugin

Mar 29, 2019

Bootstrap daterangepicker example using daterangepicker plugin

In this tutorial, we are going to look at how to create bootstrap daterangepicker in our project, then you can use date range picker easily using daterangepicker.js plugin. In this post i give you full example. So just copy bellow code and run in your browser.

Include following files in your webpage into the head tag

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<link rel="stylesheet" type="text/css" href="" />

Now, add below HTML code in body tage

<div id="reportrange" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 30%">
    <i class="fa fa-calendar"></i>&nbsp;
    <span></span> <i class="fa fa-caret-down"></i>

Now, add below js code before close body tage

<script type="text/javascript">
$(function() {

    var start = moment().subtract(29, 'days');
    var end = moment();

    function cb(start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));

        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);


Copyright 2024. All rights are reserved