Showing user an image dynamically for a day?


I wanted to see if someone can help with this issue.

I wanted to add this small feature for our site.  Basically when a user creates a new document in our web based app, we show the user a list of the documents associated with their account in a nice html table.  Their documents are listed as hyperlinks.

I want to display a simple image on my page that has the words "new" on it next to the hyperlink if the document was created "today".  So for the whole day the user would see the *New* image next to the hyperlink.

The next day when the user logs in, the new image would be gone as it would be the next day.

How can I accomplish this?  Does it involve client variables or would it be done through a cookie?  If user does not accept cookies, what alternatives are there?  It is my understanding that client variables compare the information from a db or a registry to a cookie on the users machine so if the user does not have cookies enabled, what does the client var in our db compare itself to???



Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Hey West,

All you need is the age of the document.

Wether it's a file or a record in a database, there should be a date associated with it's creation.  Use that date to determine wether the 'new' graphic gets displayed or not:

<cfif datediff(userdocument.date_added, now()) LTE 0><img src="/images/new.gif"></cfif>

Something like that.


Westside2004Author Commented:
Yes, that makes sense..

Will try what you gave me..

I am basically looking to show the image if the document is 6 hours old or less, if so, mark it new by showing the new img

Otherwise, don't show any image at all..



I was just looking at the code I posted.  I don't know what I was thinking about, but the syntax is wrong.

Should have been:

<cfif datediff("h", userdocument.date_added, now()) GTE 6><img src="/images/new.gif"></cfif>



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Westside2004Author Commented:

Will try it now..

What is the "h"?
Hi Westside2004,
seth has good suggestion. h stands for hour. As you are looking for six hours difference.

Westside2004Author Commented:

I thought that... but wanted to just make sure...


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.