I wrote some code to compare 2 time in string format (HH:MM:SS).
var time = new Date();
var current_time_str = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
var deadline= "16:00:00" //hh:mm:ss
if ( (current_time_str) > (deadline))
{
console.log("deadline has passed");
}
The code actually works by simply comparing the string. However, I am worried if it worked only coincidentally by luck because the string is just an ASCII representation. Are there other ways to compare the 2 time? I am using node.js