Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to display file Modified Date and Time in HTML ?

Status
Not open for further replies.

Recce

Programmer
Aug 28, 2002
425
ZA
Hi,

I need to display the file modified date & time of an Excel file in my HTML page. I take it the folowing code should do the trick however, I have no idea how to display this in a label, button or text box. Can anyone tell me if I am on the right track or not. Thanks :->


<script
function ShowFileAccessInfo(filespec)
{
var fso, f, s;
fso = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
f = fso.GetFile(filespec);
s = filespec.toUpperCase() + &quot;<br>&quot;;
s += &quot;Created: &quot; + f.DateCreated + &quot;<br>&quot;;
s += &quot;Last Accessed: &quot; + f.DateLastAccessed + &quot;<br>&quot;;
s += &quot;Last Modified: &quot; + f.DateLastModified;
return(s);
}
</script>
 
This is how you would do if, if that script worked for you.

<body onload=displaydate()>
<form method=post action=page2.asp>
<input type=text name=text value=&quot;text&quot;>
<input type=submit>
</form>
<input type=text id=filedate>
<script>
function displaydate(){
var strFile
strFile=ShowFileAccessInfo('page1.htm')
filedate.value=strFile
}

I get an error with that object.
 
Here it is, but because it is ActiveX, you do get a warning.
You might want to do it &quot;server side&quot; with ASP.
<html>
<!-- Creation date: 9/9/2003 -->
<head>
<title></title>
<meta name=&quot;description&quot; content=&quot;&quot;>
<meta name=&quot;keywords&quot; content=&quot;&quot;>
<meta name=&quot;author&quot; content=&quot;Van Eerden Distribution&quot;>
<meta name=&quot;generator&quot; content=&quot;AceHTML 5 Pro&quot;>
</head>
<body onload=displaydate()>
<p id=moddate></p>
<script>
function displaydate(){
var strFile
strFile=ShowFileAccessInfo('page1.htm')
moddate.innerHTML=strFile
}
function ShowFileAccessInfo(filespec)
{
var fso, f, s;
fso = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
f = fso.GetFile(filespec);
s = filespec.toUpperCase() + &quot;<br>&quot;;
s += &quot;Created: &quot; + f.DateCreated + &quot;<br>&quot;;
s += &quot;Last Accessed: &quot; + f.DateLastAccessed + &quot;<br>&quot;;
s += &quot;Last Modified: &quot; + f.DateLastModified;
return(s);
}
</script>

</body>
</html>


 
Hi VEWebGuy,

Thanks, for this.It worked but, yes, the about ActiveX that you spoke about is exactly what I got.Can you briefly explain the difference between server side and client side to me, please. :)

Thanks
 
Server Side Means the code runs on an server, in this case a microsoft server, such as IIS or Personal Web Server. the extension asp is what tells IIS to the page has server side code, the <% %>tags are the code that is run on the server.

Code for page1.asp - place in root of or change server mappath variable.

<?XML version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot;
&quot;<html xmlns=&quot;<head>
<title>page1.asp</title>
</head>
<body>
<%
Set MyDirectory=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set MyFiles=MyDirectory.GetFolder(Server.MapPath(&quot;/&quot;))
Set s = MyFiles.files(&quot;page1.asp&quot;)
Response.write(&quot;Name:&quot; & s.Name & &quot;<br>Created:&quot; & s.DateCreated & s.DateLastAccessed & s.DateLastAccessed)
%>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top