Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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

This comment has been minimized.

Copy link

dimitrisscript commented Feb 18, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.