Forum Moderators: open

Message Too Old, No Replies

Last Motified Dates for a list of files

Last Motified Dates for a list of files

         

jkrischt

8:32 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



I have a list of files that I need to get the date it was last modified and then list that info on a webpage. Does anyone know how I can do this?

Reflection

8:57 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



If you want to get the last modified date of the current page you can use document.lastModified which will return a string with the last modified date and time(which you probably want to remove). Not sure how you would go about getting the last modified date for a list of files though.

wkitty42

8:57 pm on Aug 14, 2003 (gmt 0)

10+ Year Member



do you have any particular scripting languages in mind or that you prefer? seems that this may be done as a cgi or possibly even as a static updated page where its updated (regenerated, actually ;)) when one or more of the pages are updated... or just do it in a nightly event...

either way, i know that perl and php can do this as well as rexx... hopefully others will pipe in here with additional info and/or examples...

macrost

2:01 am on Aug 15, 2003 (gmt 0)

10+ Year Member



Welcome to Webmasterworld! If you use ASP, then you can utilize the FSO object and pull the last modified date from the file(s) that the server has time/date stamped. If you need some help, I have some code...
;)

Mac

jkrischt

12:21 pm on Aug 15, 2003 (gmt 0)

10+ Year Member



Thanks for your all you help!

I actually wanted to stear clear of ASP because the server I'm using doesn't have it activiated. I know a great deal about ASP and could do it with that, but little about Javascript. I really wanted to be able to do it using Javascript. Does anyone know how?

Looks like I may be stuck gettig ASP installed!

g1smd

6:38 pm on Aug 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can PHP do any of that stuff?

Rumour has it that PHP is a tad simpler to use and a bit easier to learn too.

garann

11:44 pm on Aug 18, 2003 (gmt 0)

10+ Year Member



Any decent server side scripting language should be able to do this easily. If you really want JavaScript, you could do it with an iframe or a popup or a hidden frame.

You could have your main page running a script which runs through an array of the files whose last modified dates you want. That loop would
1. load the file in the iframe/popup/hidden frame
2. get the last modified date of the document in the iframe/popup/frame
3. repeat until the end of the array

hth,
g.

MonkeeSage

2:40 am on Aug 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Page based on garann's suggestion (only works on pages local to the server this file resides on because of iframe security issues):

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
<title>Last Modified</title>
<style type="text/css">
#lmh {
border: none;
padding: none;
margin: none;
}
#lmih {
float: right;
border: 1px dashed gray;
}
.mi {
border: 1px dashed gray;
margin: 2px;
padding: 2px;
}
</style>
<script type="text/javascript">
<!--
var mods = new Array(5);
mods[0] = "file1.htm";
mods[1] = "file2.htm";
mods[2] = "file3.htm";
mods[3] = "file4.htm";
mods[4] = "file5.htm";
function getMods() {
for (var i = 0; i < mods.length; ++i) {
makeFrame(mods[i], document.getElementById("lmh"), i);
}
var tmr = setTimeout('getMod()', 5000);
}
function getMod() {
for (var i = 0; i < mods.length; ++i) {
doGetMod(mods[i], document.getElementById("lmi"), i);
}
}
function makeFrame(file, divElm, count) {
var frm = document.createElement("iframe");
frm.src = file;
frm.setAttribute("id", ("ifrm" + count));
frm.setAttribute("width", "200px");
frm.setAttribute("height", "185px");
divElm.appendChild(frm);
}
function doGetMod(file, divElm, count) {
var p = document.createElement("p");
p.setAttribute("class", "mi");
p.innerHTML = file + ": Last Modified:<br />" +
window.frames[count].document.lastModified +
"<br /><br />";
divElm.appendChild(p);
document.getElementById("mb").setAttribute("onclick",
"window.location.reload();");
}
//-->
</script>
</head>
<body>
<div id="lmh">
</div>
<div id="lmih">
<div id="lmi"></div>
<div><input id="ms" type="button" value="Get Last Modified"
onclick="getMods();"/></div>
</div>
</body>
</html>

HTH
Jordan