Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Posted "today,yesterday, n days ago"

Posted on 2006-10-19
2
Medium Priority
?
256 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
[X]
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
2 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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