Finding the Last Modified Date on a File
This question came up on my local CFUG mailing list yesterday:
how can I get the time last updated of the two documents? I know you can do this with uploaded files using FILE.TimeLastModified. Is there anyway to do it with existing files? I know I could do a hack with CFDIRECTORY where I loop through the files in the directory looking for the one I'm interested in and then getting the dateLastModified on that, but I'm thinking there has to be a more direct way.
You can use java's File class to get the lastModified timestamp:
<cfset myFile = CreateObject("java", "java.io.File")> <cfset myFile.init("/path/to/file")> <cfset last_modified = myFile.lastModified()>
Like this? Follow me ↯Tweet Follow @pfreitag
Finding the Last Modified Date on a File was first published on January 11, 2007.
If you like reading about java, coldfusion, file, or cfdirectory then you might also like:
- URL Safe Base64 Encoding / Decoding in CFML
- Updating Java on ColdFusion or Lucee
- Getting Size of Heap and Non Heap Memory in CFML
- Adobe Says Go Ahead and Upgrade your ColdFusion JVM
- HashDOS and ColdFusion
- Using AntiSamy with ColdFusion
- OutOfMemoryError - GC overhead limit exceeded
- What Version of Java is ColdFusion Using?
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.