Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Posted "today,yesterday, n days ago"

Posted on 2006-10-19
2
Medium Priority
?
257 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

972 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