I\'m trying to write a statement that says \"if time is this and less than that then\". I can use get hours and get min. However, I\'m having problems combining a time suc
I made this solution simple and easy to read (thus easy to adjust) by using a simple trick.
The trick is to transform the hour and minutes into a number. Eg 09:30 into 9.30
var now = new Date();
var hour = now.getHours();
var minutes = now.getMinutes();
// make the current time of day computable and readable at the same time
// 9:30 becomes 9.30
var timeOfDay = hour + (minutes / 100);
console.log('timeOfDay: ' + timeOfDay);
// For setting the time limits simply use the time with a dot instead of a colon
if( (9.30 <= timeOfDay) && (timeOfDay <= 11.30) ){
console.log('Time is between 9:30 and 11:30');
}