i have two text fields containing time value stored in "hh:mm:ss" format.
i need to have a comparison between them, if they are equal or which one is bigger
in the attached image, you can find the fields
Hi @MehmetMuhanna,
Try this approach:
function parseTime(timeString) {
let date = new Date();
let [hours, minutes, seconds] = timeString.split(':');
date.setHours(+hours);
date.setMinutes(+minutes);
date.setSeconds(+seconds);
return date;
}
fd.rendered(() => {
alert(parseTime("11:19:02") > parseTime("19:11:02"));
});
You can use the parseTime() function to convert any string in the format "hh:mm:ss" into a date object.
Hi @MehmetMuhanna ,
another idea is to split the time as @IliaLazarevskii supposed to do so and work with 60 seconds for one minute, 60 minutes to one hour and work with mathematics a bit in the code.
But @IliaLazarevskii 's solution is probably one of the best one.
Stepan