I have the following code, with this I can add a class (today) in a div. Now what I need is to be able to do the following,
18:00 - 20:00
I want to be able to calculate that if the time range is not between 18:00 y 20:00
, add a text even div that says (Closed).
var d = new Date();
var n = d.getDay();
n = n > 0 ? n - 1 : 6; // zero is sunday, not monday in javascript
$('li.week').eq(n).addClass('today');
UPDATE
Now I have the following.
var start = new Date('18:00').getTime();
var end = new Date('20:00').getTime();
var now = new Date().getTime();
if( (start < now )) {
alert("opened");
}
else {
alert("closed");
}
I only have one problem I can not find a way to get the time validated with another.
18:00 a 20:00
If you are not in that time range, you should say Closed.