2015-06-05 2 views

ответ

0

Итак, при загрузке веб-страницы виджет будет показан только в том случае, если они находятся между 6 утра и 6 вечера? Понимая, что да, простая логика ... see it working и see the reference

var nowIs = new Date(); 
// if you need to compare the seconds or minutes can use nowIs.getMinutes() and nowIs.getSeconds() 
// se more in http://www.w3schools.com/jsref/jsref_obj_date.asp 
if(nowIs.getHours() >= 6 && nowIs.getHours() <= 18){ 
    alert("Hey, now is between 6am and 6pm :)"); 
}else{ 
    alert("That bad, now is not between 6am and 6pm :("); 
} 
Смежные вопросы