Skip to content

Instantly share code, notes, and snippets.

@dangrossman
Created April 28, 2018 20:01
Show Gist options
  • Save dangrossman/d50376f3467f69e7fb5570afd07dc921 to your computer and use it in GitHub Desktop.
Save dangrossman/d50376f3467f69e7fb5570afd07dc921 to your computer and use it in GitHub Desktop.
<input type="text" name="datefilter" value="" />
<script type="text/javascript">
$(function() {
$('input[name="datefilter"]').daterangepicker({
autoUpdateInput: false,
locale: {
cancelLabel: 'Clear'
}
});
$('input[name="datefilter"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
});
$('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
});
});
</script>
@dimitrisscript
Copy link

If this is supposed to start with a blank date, why does:

$('input[name="datefilter"]').data('daterangepicker').startDate.format('YYYY-MM-DD');

return today's date instead of null?

@its-kayes
Copy link

How could I implement this on React ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment