One way you could do this, if the time is a string and always in the HH:MM 24 hour format, is parse the string and convert it into a number of minutes before performing the comparison. For example:
var time1 = "10:30";
var time2 = "12:30";
var time1InMinutesForTime1 = getTimeAsNumberOfMinutes(time1);
var time1InMinutesForTime2 = getTimeAsNumberOfMinutes(time2);
var time1IsBeforeTime2 = time1InMinutesForTime1 < time1InMinutesForTime2;
function getTimeAsNumberOfMinutes(time)
{
var timeParts = time.split(":");
var timeInMinutes = (timeParts[0] * 60) + timeParts[1];
return timeInMinutes;
}
In this example, time1
will work out at 60,030 minutes and time2
will work out at 72,030 minutes, turning the comparison into a check between two numbers.