Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Posted "today,yesterday, n days ago"

Posted on 2006-10-19
2
251 Views
Last Modified: 2013-12-24
For my crmercado.com site, I show the date posted - boring.

I would like to emphasise that my site is posting 2-3 times daily..

How can I take the date value and display it as follows:

If DatePosted "day" is equal to Now()= "Today"
1 day ago = "Yesterday"
2+ = "N days ago"
0
Comment
Question by:mcsolas
2 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 17769614

 <cfset variables.number_of_days = dateDiff("d",  variables.PostedDate,  now())>

 <cfswitch expression="#variables.number_of_days#">
    <cfcase value="0"> Today</cfcase>
    <cfcase value="1"> Yesterday </cfcase>
    <cfdefaultcase> #variables.number_of_days# days ago</cfdefaultcase>
 </cfswitch>
0
 
LVL 1

Author Comment

by:mcsolas
ID: 17769799
exactly what I needed
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Website Test Question 6 126
Problem to get function 52 112
How code a 301 redirect for folder files -> 1 file 2 58
Two wordpress questions 3 61
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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