0

I have two input fields, one start and one end time. They are both in 24 hour format and is displayed this way: Start time: 01:10 End Time: 23:04 but if I inspect the input I can see that the value is really saved as this: Start time: 1:10 and End time: 23:4.

I want to compare these two times, and if they are identical, give a warning, and if the start time is greater than the end time give another warning. This is where I am at:

$('#publish').click(function()  {
    var quantityI =  parseInt($('#time_from').val());
    var quantity = parseInt($('#time_to').val());
    /* If start time is greater then end time, show alert */
    if( quantityI > quantity) {
        $('#alert_slide_start_end_time').modal({
        });
        return false;
    }
    /* If start time and end time is identical, show alert */
    else if( quantityI = quantity) {
        $('#alert_slide_start_end_time_identical').modal({
        });
        return false;
    }
    else {
    }
});

The problem is that the compare I am doing doesn't seem to work with the format? Is it possible to convert the time into epoch and then compare it? Or what is the best approach?

EDIT: Solution here: Compare start time amd end time with jquery?

joq3
  • 145
  • 7

0 Answers0