Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Something like this would work:

let currentTime = new Date().getHours();
let img = document.getElementById('myImage')

if (currentTime >= 0 && currentTime <= 11) {
  img.src = 'image 1 link'
} else if (currentTime >= 12 && currentTime <= 18) {
  img.src = 'image 2 link'
} else if (currentTime >= 19 && currentTime <= 23) {
  img.src = 'image 3 link'
}

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!