When did you last change a web page?

Have you ever wanted to dynamically display the last date modified on a page for your site?

This tutorial will show you how to do this on each page and it will also show you how to display a list of many files in a single location...

Let's begin,

The first example will show you how to incorporate this into the page the visitor is calling.. so when your visitor is visiting the "index.cfm" page it will show the last date modified... etc..

The first thing you do is is to create your actual page... we'll use the page called "index.cfm" as an example..

<!--- index.cfm page begins --->


<!--- display the last date modified area --->
<cfdirectory action="list"
"#ListLast(CGI.SCRIPT_NAME, "/")#">

<cfif qGetLastdateModified.recordCount>
This page was last modified on : #DateFormat(qGetLastdateModified.dateLastModified, "mm/dd/yyyy")# </cfoutput>

<!--- index.cfm page ends --->

What this does is basically call <CFDIRECTORY> to call the page being called and get the last date modified for that particular file.

The next example will allow you to set a variable that contains a list of files you want to report a last date modified for, let's begin:

<cfset fileList = "index.cfm,page2.cfm,page3.cfm">

<cfloop list=
"#fileList#" index="page">
  <cfdirectory action=
  #page# was last modified on : #DateFormat(qGetFileDate.dateLastModified, "mm/dd/yyyy")#<BR>

So now you will be able to alert your visitors on when was the last time you modified a web page!

Questions? Comments? Please let me know by emailing me or by posting your questions on the EasyCFM forums!

About This Tutorial
Author: Pablo Varando
Skill Level: Beginner 
Platforms Tested: CF4,CF5,CFMX,BlueDragon
Total Views: 92,305
Submission Date: April 12, 2004
Last Update Date: June 05, 2009
All Tutorials By This Autor: 47
Discuss This Tutorial
  • Hi, I stumbled across a cold fusion scrift on your page when looking to add a last modified function to a page. My task is to find pages which havent been updated between certain time periods or in the last x amount of time. To do this manually would be painstaking as the site in hand is already quite large, and will continuously grow over the coming year. Can the second half of the script be modified to do this?

  • ..you simply insert this 03.11.2004 wherever you want to display the date when the page was last modified *cough*

  • You're welcome, we're here to help you learn ColdFusion, Easily! :)

  • This is exactly what I was looking for! Thanks sooooooo much! -Dave


Website Designed and Developed by Pablo Varando.