I have found a function which returns file info: GetFileInfo()
It returns following data:
But this data does not show when the file was actually created. How to find it out?
Use the Now() function to obtain the current date and time from the server. Continuing onward, we can customize the date format even more by specifying a mask in the DateFormat() function. The TimeFormat() function is similar to DateFormat(), except, of course, that it returns the time.
Hence, dateformat(now(), "mm-D-yyyy") is the same as dateformat(now(), "mm-d-yyyy") when flag is set to true. By default Capital D is used to specify Day of the year. See example below. ColdFusion (2018 release) Update 3.
(From comments ...)
It was probably omitted because it is o/s level metadata. Assuming creation date is supported on your o/s, try using java.nio:
<cfscript>
physicalPath = "c:/path/to/someFile.ext";
// Get file attributes using NIO
nioPath = createObject("java", "java.nio.file.Paths").get( physicalPath, [] );
nioAttributes = createObject("java", "java.nio.file.attribute.BasicFileAttributes");
nioFiles = createObject("java", "java.nio.file.Files");
fileAttr = nioFiles.readAttributes(nioPath, nioAttributes.getClass(), []);
// Display NIO results as date objects
writeOutput("<br> creation (date): "& parseDateTime(fileAttr.creationTime()));
writeOutput("<br> modified (date): "& parseDateTime(fileAttr.lastModifiedTime()));
// Display CF results for comparison
fileInfo = getFileInfo(physicalPath);
writeDump(fileInfo);
</cfscript>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With