I'm doing this atm also, I'm using this library: https://github.com/dangrossman/daterangepicker
It's pretty good and does exactly what you need.
initialize the field
$(function () {
$('input[name="datetime"]').daterangepicker({
timePicker: true,
timePicker24Hour: true,
startDate: moment().startOf('day'),
endDate: moment().startOf('day').add(24, 'hours'),
locale: {
format: 'MM/DD/YYYY HH:mm'
}
});
});
To save it in the database you can simply explode the from / to date strings
$fromDateTime = trim(explode('-', $request->get('datetime'))[0]);
$toDateTime = trim(explode('-', $request->get('datetime'))[1]);
And then query like
->whereDate('table_name.updated_at', '>=', Carbon::parse($fromDateTime))
->whereDate('table_name.updated_at', '<=', Carbon::parse($toDateTime))