Grow your CSS skills. Land your dream job.

Daily image

  • # August 26, 2008 at 8:12 am

    I’ve got a folder of images, each titled with a date, such as 051508.jpg. Is there a way to get it to automatically use the correct image on the correct day (according to my time zone)? I know there’s a way to grab a random image every time the page reloads, but I need a specific image for a specific day.

    TIA!

    # August 26, 2008 at 8:42 am

    you can do it with php:

    <img src="folder/to/images/<?php echo date(‘dmy’)?>.jpg" alt="daily img"/>

    box
    # August 26, 2008 at 8:46 am

    php, use <?php echo date(mdy); ?>.jpg

    *Argeaux beat me to it

    As you can see with these two examples, you can change the order of the letters to layout the date in American format as per your example.

    # August 26, 2008 at 9:38 am

    Thanks for the help guys. You definitely put me on the right track. I found a site online that explains all the different date and time formats.

    It’s not pulling the image up however when I put the code in. It comes in as an empty box with the little missing image icon. When I right-click and "Open image in new window", it gives me a page not found with the url being:

    /gag_toons/%3C?php%20echo%20date(‘dmy’)?%3E.gif

    with gag_toons/ being the directory where my images are stored. I’ve renamed them to 08262008.gif and so on. Based on the code you gave me, here’s is what I’m using to call the image:

    <img src="gag_toons/<?php echo date(‘dmy’)?>.gif" width="245" height="197" alt="daily img"/>

    Any ideas?

    box
    # August 26, 2008 at 9:44 am

    Does your file have a php extension? Does your server have php installed?

    # August 26, 2008 at 10:09 am

    Well, I didn’t, but I’ve changed it and I get the same results. According to GoDaddy I do have php installed. Is there any easy way to check to make sure that it is? Any other ideas?

    # August 26, 2008 at 10:12 am

    Never mind – I just figured out the problem. Part of it was that I didn’t have .php as the file extension. When I changed that, the image still wasn’t loading. When I right-clicked and opened the image in a new window, I found what the problem was. The echo date was giving the date differently than I had thought (and different than what the website that I used as reference said).

    I renamed my image, and it is working now.

    Thanks for all your help!!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".