Skip to content

Instantly share code, notes, and snippets.

@dilanWijerathne
Forked from dangrossman/DRP Example 4.js
Created February 2, 2016 06:42
Show Gist options
  • Save dilanWijerathne/3b47b74c8d0ab0fc1abd to your computer and use it in GitHub Desktop.
Save dilanWijerathne/3b47b74c8d0ab0fc1abd to your computer and use it in GitHub Desktop.
DRP Example 4.js
<div id="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>&nbsp;
<span></span> <b class="caret"></b>
</div>
<script type="text/javascript">
$(function() {
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
}
cb(moment().subtract(29, 'days'), moment());
$('#reportrange').daterangepicker({
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);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment