+ 1

Can you change an image according to the hour and minute of the day?

this is the script but it does not comply with what I ask for I am new to this function carregar (){ var img = document.getElementById("imagem") var data = new Date() var hora = data.getHours() var min = data.getMinutes() if(hora >= 5 && min>= 00 && hora <=7 && min<=30 ){ img.src = "0.jpg" }else if(hora >= 7 && min>= 30 && hora <=9 && min<=30 ){ img.src = "1.jpg" }else{ img.src = "2.jpg" } }

6th Apr 2022, 6:53 AM
Music to relax
2 Antworten
+ 1
Add: onload=()=>carregar()
6th Apr 2022, 7:35 AM
Solo
Solo - avatar
0
You use it according to 24-digit. If you're are trying to change the omg when it's 5, use ...hora>=17...
6th Apr 2022, 7:21 AM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar