Skip to content
Advertisement

Changes image based on time of day

good evening all. I’am a beginner programmer, I need your help in changing the image based on the time of day. for example:

  • 00-11am = image A
  • 12pm-18pm = image B
  • 19pm-23pm = image C

Can anyone help me? I know that I need to use JS but I don’t know how to implement it properly. Thanks

Advertisement

Answer

Something like this would work:

JavaScript

change myImage to whatever your images ID is, and change the image sources to the links to your image files.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement