Display information for a specified date range

Use a cfif statement and a couple of functions so you can have information appear/disappear based on the date:

Functions used:

  • now()
    the date and time right now.
  • createdate ( year, month, day )
    The date with the supplied year, month and day.
  • createDateTime (year, month, day, hour, minute, second)
    get specific with the date and time.

Example: show information as long as the current date is before June 1st 2008. (until 11:59pm 5/31/2008).
There’s a deadline for the published information.

<cfif now() LT createdate(2008,6,1)>
Show this information
</cfif>

Example: show information only during the first seven days of June 2008
The information isn’t valid until a future date, and there’s a time limit on the information.

<cfif now() GT createdate(2008,5,31) AND now() LT createdate(2008,6,8)>
Show this information
</cfif>

~ by chipster621 on May 12, 2008.

One Response to “Display information for a specified date range”

  1. Thanks. Just what I was looking for.

Leave a Reply