Get the ASP Developers widget and many other great free widgets at Widgetbox! ASP Developers: How to retrive the last updateed date of a page.

Wednesday, May 30, 2007

How to retrive the last updateed date of a page.

Summary:- This function is very useful for getting the date that the document was last modified.

ASP Code:-

<%
Function LastUpdated
Dim fso, thispage, fileObject, datemodified
Set fs = CreateObject("Scripting.FileSystemObject")
thispage = replace(request.ServerVariables("URL"), "/", "\")
Set fileObject = fs.GetFile(server.MapPath(thispage))
datemodified = fileObject.DateLastModified
LastUpdated = (FormatDateTime(datemodified, 1))
Set fileObject = Nothing
Set fs = Nothing
End function
%>

<% Response.write ("Last Updated: " & lastUpdated)
'--- returns: Last Updated: Wednesday 30 May 2007%>

0 Comments: