I need to validate time picked by user, start date must be greater than 6 am and smaller than end date which must not exceed next day 2 am.
though I dont have date as an input I assume I should append dates to the picked times to compare, is this the best way to achieve it or there is a smarter one ?
here is what I can think of so far
function compareTimes(start,end){
var t1 = new date();
var t2 = new date();
var starttime = t1 + " " + start;
if (end >= '00:00'){
t2.setDate(t2.getDate()+1);
}
var endtime = t2 + " " + end;
if(Date.parse ( endtime ) > Date.parse ( starttime )){
alert ("greater than");
return true
}
}
startandendparameters? It looks to be a string, formatted asHH:nn, but is it guaranteed to be that?