JSFiddle - React, Tailwind, and code Playground
JavaScript
// Verifica se hora1 Ă© maior que hora2.
function compararHora(hora1, hora2)
{
hora1 = hora1.split(":");
hora2 = hora2.split(":");
var d = new Date();
var data1 = new Date(d.getFullYear(), d.getMonth(), d.getDate(), hora1[0], hora1[1]);
var data2 = new Date(d.getFullYear(), d.getMonth(), d.getDate(), hora2[0], hora2[1]);
return data1 > data2;
};
console.log(compararHora('07:30', '08:00'));
console.log(compararHora('08:30', '09:00'));
console.log(compararHora('09:00', '8:00'));
console.log(compararHora('15:31', '15:30'));