javascript - Incorrect date and time when using Date Range Picker -
i'm using plugin date range picker plugin predefined range. problem "last 30 minutes" not showing correct date range.
what expect:
say january 28, 2016 17:00 pm
, when select last 30 minutes, expect show january 28, 2016 16:30 pm
- january 28, 2016 17:00 pm
.
what got
january 28, 2016 12:00 am
- january 28, 2016 11:59 pm
the rest of predefined template seems work. here's a fiddle play.
you need enable timepicker feature this:
$(function() { function cb(start, end) { $('#reportrange span').html(start.format('mmmm d, yyyy h:mm a') + ' - ' + end.format('mmmm d, yyyy h:mm a')); } cb(moment().subtract(29, 'days'), moment()); $('#reportrange').daterangepicker({ timepicker: true, /*add line*/ ranges: { 'last 30 minutes': [moment().subtract(30, 'minutes'), moment()], '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); });
Comments
Post a Comment