-4
You are comparing the variable "Time", a string, with an integer
if(hora > 0 && hora <=12) { ...}
This will always fall into Isis, so it will always fall into the image of the night.
Do:
var hora = date.getHours();
if( hora >= 0 and hora < 12 ) {
sua imagem manhã
} else if (hora < 18) {
sua imagem da tarde
} else { sua imagem da noite }
With this, whenever you use the function "getHours()", it will bring you the whole hour, so just compare it, because 11:1 and 11:59 will have return 11.
Post the code, not the code image that makes it easier for people to help you
– Benilson
In that code of yours,
hora
will be a string in formatHH:MM
. There’s no point comparing this string with numerical values like you’re doing in your code, which is why you’re always falling intoelse
.– Andre
Great reasons not to use images when using text: https://pt.meta.stackoverflow.com/a/7817/3635
– Guilherme Nascimento