Jaggi Jaggi - 2 months ago 31
Javascript Question

How to make bootstrap-datetimepicker to show time in 15 minutes interval

This is my Javascript code to increment in minutes in interval 1

fillMinutes = function () {
var table = widget.find('.timepicker-minutes table'),
currentMinute = viewDate.clone().startOf('h'),
html = [],
row = $('<tr>'),
step = options.stepping === 1 ? 5 : options.stepping;

while (viewDate.isSame(currentMinute, 'h')) {
if (currentMinute.minute() % (step * 4) === 0) {
row = $('<tr>');
html.push(row);
}
row.append('<td data-action="selectMinute" class="minute' + (!isValid(currentMinute, 'm') ? ' disabled' : '') + '">' + currentMinute.format('mm') + '</td>');
currentMinute.add(step, 'm');
}
table.empty().append(html);
}


I want to modify this to increment in 15 minutes interval.
Can someone help me on this.

Answer
incrementMinutes: function () {
                    var newDate = date.clone().add(15, 'm');
                    if (isValid(newDate, 'm')) {
                        setValue(newDate);
                    }
                }



decrementMinutes: function () {
                    var newDate = date.clone().subtract(15, 'm');
                    if (isValid(newDate, 'm')) {
                        setValue(newDate);
                    }
                }