I have two time in the format "HH:MM" i want to compare them i have the following code to get the time of now in my format:
current_time = new Date();
hour = current_time.getHours();
minute = current_time.getMinutes();
if(hour<10){hour='0'+hour} if(minute<10){minute='0'+minute}
my_time = hour+':'+minute;
And this code is to get the time after subtracting the GMT difference :
d = new Date()
var n = d.getTimezoneOffset();
var n1 = Math.abs(n);
var difference = (n1/60);
my_time = my_time - (0+difference);
Now the value of my_time should be compared with the value of match_time:
match_time = 10:00;//for example
if(my_time > match_time)
{
alert('yes');
}
else
{
alert('No');
}
how can I compare those values as time when they are a string ???
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…