JQuery UI - Set minTime on timepicker based on other timepicker value

BeardedGeek picture BeardedGeek · Mar 21, 2012 · Viewed 16.6k times · Source

I'm trying to set the minTime of my End Time timepicker based on what I've selected in the Start Time timepicker.

I have this, based on something that works for the regular datepicker, but it's not working.

$('#confirmed_time_start').timepicker({
    timeFormat: 'hh:mm',
    stepHour: 1,
    stepMinute: 15,
    hour: 8,
    minute: 0,
    hourMin: 8,
    hourMax: 18,
    onSelect: function(timeStr) {

        var newTime = $(this).timepicker('getDate');
        if (newTime) { // Not null
        newTime.setDate(newTime.getDate());
        }
        $('#confirmed_time_end').timepicker('minTime', newTime)
        }

    });

$('#confirmed_time_end').timepicker({
    timeFormat: 'hh:mm',
    stepHour: 1,
    stepMinute: 15,
    hour: 8,
    minute: 0,
    hourMin: 8,
    hourMax: 18 
    });

The error I'm receiving is:

Object doesn't support this property or method

Answer

Jyoti picture Jyoti · Jul 10, 2013
$('#confirmed_time_start').timepicker({
timeFormat: 'hh:mm',
stepHour: 1,
stepMinute: 15,
hour: 8,
minute: 0,
hourMin: 8,
hourMax: 18,
onSelect: function(timeStr) {

    var newTime = $(this).timepicker('getDate');
    if (newTime) { // Not null
    newTime.setDate(newTime.getDate());
    }
   $('#confirmed_time_end').timepicker('setTime', newTime);
    }

});