Javascript - How to set different date/time for each photo to appear

Hello, how can I write this to set each image to appear on a certain date & time each?

One way you could do this is to attach a data attribute to each image and as time passes, you loop through your images, reading each data property. If the time for the image meets your requirements, then you show the image. Otherwise you move on to the next image.

This method would be easy for you to setup, as the data attribute is just another attribute of your <img> tag and just as easy to read in the data and use it to compare it to the current time. :slight_smile:

Any sample I could look at for guidance how to write with three different show image date/time
Display a current image (until the next dat/time image to appear)
Image one on 11-30-2021 4:00pm CST
Image two on 12-2-2021 8:00am CST
Image three on 12-12-21 12:00pm CST

Did you check out the link? That shows you how to setup the attributes and how to read them in JS. All that you have to do is decide when you want them to show and compare them to the current date and time.

Show us what you have setup in the code and then we can help with where you might be stuck.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.