How to get last updated & created date and time of an ASP file

We will try to develop a code for showing the last modified date and the created date of the file and display to visitors. This code has to work on it own without any input or changed settings.

We will use the FileSystemObject for getting the last changed or updated along with created date of the file. To make this code universal we will not use name of the file as input to this FileSystemObject , it its place we will use code to get the current file name and then use that as input to FileSystemObject. This way we can make it independent of file name setting and the same code can be used inside any asp file without any changes.

Before reading this it is advisable to read the FileSystemObject and how to get the file name of the current script running page. With this knowledge we can add more code to get the last updated time of the file.

Here is the code to get the current file name and FileSystemObject created.

Dim objFSO, objFile, fname, fullname, my_array
fullname = Request.ServerVariables("SCRIPT_NAME")

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(Server.MapPath(fname))

To these lines we will add the file name and DateCreated and DateLastModified to get the full code to display the modified time.

Response.Write "Created date of file "& objFile.Name & " = " & objFile.DateCreated
Response.Write "
Last Modified date of file "& objFile.Name & " = " & objFile.DateLastModified

Note that the above code can be used in any asp file without any modification to get the last updating and creating date and time of the file. Similar code to get the last modified date and time can be developed using PHP script.

Be the first to post comment on this article :

Post your comments , suggestion , error , requirements etc here .

We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer