Why this code becomes true?
timenow = '14:57';
if((timenow >= '0:00') && (timenow < '6:00')) {
alert('true');
}
What is wrong with this simple if
Moderator: General Moderators
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: What is wrong with this simple if
Because you're comparing strings (alphabetically), not numbers.
There are 10 types of people in this world, those who understand binary and those who don't
Re: What is wrong with this simple if
Use zero placeholders, as in '00:00' and '06:00'.
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: What is wrong with this simple if
But how to compare hours?