Eu gostaria de saber como coloco para um código estar ativo entre determinadas horas, que neste caso seria entre as 7h e as 22h do fuso horário Brasília.
Tentei estudar este que já contém essa função, pórem não entendi:
var horaAtual = (new Date()).getHours();
var imagem = "";
if(horaAtual >= horario_inicio["manhã"] && horaAtual < horario_inicio
["tarde"]){
imagem = imagens["manhã"];
}else if(horaAtual >= horario_inicio["tarde"] && horaAtual <
horario_inicio["noite"]){
imagen = imagens["tarde"];
}else if(horaAtual >= horario_inicio["noite"] || horaAtual < horario_inicio
["manhã"]){
imagen = imagens["noite"];
}
if(imagem_se_repete){
jQuery(seletor_css).css("background", "url(" + imagem + ") repeat");
}else{
jQuery(seletor_css).css({"background-image":"url(" + imagem + ")",
"background-repeat":"no-repeat", "background-size":"cover"});
}
});
O código em que quero colocar horário de funcionamento é o seguinte:
$(function() {
$(".post").each(function() {
if (_userdata.user_level == 2 || _userdata.user_level == 1) {
return;
}
if($('.pathname-box:contains(Tarefas), .pathname-box:contains(Redações)').length > 0) {
var username = _userdata.username;
if ($(this).has('.staff').length) {
return;
}
if($(this).html().indexOf(username) <= 1) {
$(this).remove();
}
if($(this).html().indexOf(username) >= 1) {
$(this).remove();
}
}
});
});