Automation of Image Update based on Date

Posted on 2009-12-22
Last Modified: 2013-12-24
I am trying to basically have an image that's on a web page update based on the date.  So for example, when it hits the 1st of January it will change back to it's original image.  Right now it's set as a holiday image.  I was wondering if it was possible to do this with Coldfusion.  The server is running Coldfusion 8 if that helps any bit.  
Question by:Phylox
    LVL 15

    Expert Comment

    This quite easy:

    use like this:

    <cfif #DateFormat(now(),'mm/dd/yyyy') EQ '01/01/2010'>
         <img src="mainimage.jpg" border="0"/>
         <img src="holidayimages.jpg" border="0">

    You also also setup the dates in the database and then make the comparision above with the dates you have in database. it will automatically be doing in the for the whole year for which you want to have holidays

    LVL 27

    Accepted Solution

    >> <cfif #DateFormat(now(),'mm/dd/yyyy') EQ '01/01/2010'>

    that will make the non-holiday image display ONLY on Jan 1, and not on any other day.

    what you need is:

    <cfif datecompare('01/01/2010', now()) LTE 0>

    keep in mind, though, that this uses your server's time, not the time of your site's users. so a user coming from a timezone which is ahead of your server's timezone will still see a holiday image even though the user's time may already be past midnight of 1/1/2010


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    A short article about problems I had with the new location API and permissions in Marshmallow
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now