Copy link to clipboard
Copied
Hello, all,
I'm working on some legacy code, and the original developer was manually setting a "last modified" date on documents he worked on. I learned that there is a programmatic way of doing this, and I'm trying, but the value returned is 0.
<!--- I got this from Pete Freitag's blog. --->
<cfset thisFile = CreateObject("java","java.io.File") />
<cfset thisFile.init("" & cgi.script_name & "") />
<cfset lastMod = thisFile.lastModified() />
<cfset lastMod = DateFormat(DateAdd('s',lastMod,"January 1 1970 00:00:00"),"mmmm dd, yyyy") />
Last mod is reporting as January 1, 1970, which means that it's 0. Please advise.
V/r,
^ _ ^
Well, I think I know why it didn't work. But I found another way of doing it, that I will be using.
<cfset thisFilePath = getCurrentTemplatePath() />
<cfset lastMod = DateFormat(GetFileInfo(thisFilePath).lastmodified,'mmmm dd, yyyy') />
I was hoping to do this in application.cfc, just the once. The above method has to be put on each page, but I'm okay with that.
V/r,
^ _ ^
Copy link to clipboard
Copied
Well, I think I know why it didn't work. But I found another way of doing it, that I will be using.
<cfset thisFilePath = getCurrentTemplatePath() />
<cfset lastMod = DateFormat(GetFileInfo(thisFilePath).lastmodified,'mmmm dd, yyyy') />
I was hoping to do this in application.cfc, just the once. The above method has to be put on each page, but I'm okay with that.
V/r,
^ _ ^