3
I would like to know how to put a code to be active between certain hours, which in this case would be between 7am and 10pm of the Brasilia time zone.
I tried to study this one that already contains this function, but I didn’t understand:
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"});
}
});
The code I want to set up is as follows::
$(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();
}
}
});
});
Gave the following error: Uncaught Syntaxerror: Missing ) after argument list / code I am using: http://pastebin.com/sD7Y49Ef
– Maradinho PH
This correct, just as the AP commented he would like in Rasília’s time, and the function
getHours()
works with local time. That is there may be discrepancy, for this should be usedgetUTCHours()
which returns the universal time, however for this the AP will have to take into account this difference in its time as well.– Guilherme Lautert
@Maradinhoph the problem is in your console.log you are passing string without quotes and not concatenating
– Gabriel Rodrigues
oops! I didn’t notice that detail. It’s okay! Thanks.
– Maradinho PH