CFLib.org – Common Function Library Project

FileLastModified(filename)

Last updated June 11, 2009

author

Jesse Houwing

Version: 1 | Requires: CF6 | Library: FileSysLib

Description:
Returns the date the file was last modified. The date is adjusted according to timezone. It returns a valid coldfusion date object. It uses the standard Java File object, which makes it very fast under Coldfusion MX

Return Values:
Returns a date.

Example:

<cfset filename="c:\autoexec.bat">
<cfoutput>
    Length: #FileLastModified(filename)#<br>
</cfoutput>

Parameters:

Name Description Required
filename Name of the file. Yes

Full UDF Source:

/**
 * Returns the date the file was last modified.
 * v2 fixes for DTS by Mark Woods (mwoods@online.ie)
 * 
 * @param filename      Name of the file. (Required)
 * @return Returns a date. 
 * @author Jesse Houwing (j.houwing@student.utwente.nl) 
 * @version 1, June 11, 2009 
 */
function FileLastModified(filename){
    var oFile = createObject("java","java.io.File");
    var oDate = createObject("java","java.util.Date");
    oFile.init(fileName);
    return oDate.init(oFile.lastModified());
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson