Display Various Date Information in your ASP Pages

Display Various Date Information in your ASP Pages

There are certain scenarios where you need to display the create date or the last modified date of your document. There is a “LastModified” method in the “document” object which gives you the last modified date of the HTML document under context. This method cannot be used to get the last modified date information for an ASP page because it looks for the date information on the final HTML document which gets generated after the ASP code is processed by the web server. Due to this reason “document.LastModified” method will always give you the current date time for the HTML pages that get created as a result of ASP pages.

Here is a simple method which can be used to show date related information in the ASP pages. You can use server variable “PATH_INFO” to get the relative path of the asp page an then using “MapPath” method of “Server” object you can get the complete physical path of the ASP page under process. After this use file system objects toget various date related information for the ASP page. For example:Method GetFileDateInfo() can be used to get create date, last modified date,and last accessed date information for the ASP page under process. The codefollowing this method calls this method and writes the info to the outputHTML page using “Response” object.

 <%Sub GetFileDateInfo(dtCreateDate, dtLastModified, dtLastAccessed) Dim oFileSystemObject, oFile ' Get the Complete path of the file using server variables 
and MapPathmethod strFilePath = Server.MapPath(Request.ServerVariables("PATH_INFO")) ' Create file system object to do the remaining trick Set oFileSystemObject = Server.CreateObject
("Scripting.FileSystemObject") ' Get the handle on the file Set oFile = oFileSystemObject.GetFile(strFilePath) ' Return various date info using the properties of file object dtCreateDate = oFile.DateCreated dtLastModified = oFile.DateLastModified dtLastAccessed = oFile.DateLastAccessedEnd Sub%><% ' Show date information on the asp page Dim dtCreateDate, dtLastModified, dtLastAccessed GetFileDateInfo dtCreateDate, dtLastModified, dtLastAccessed Response.Write "Create Date : " & dtCreateDate & "
" Response.Write "Last Updated : " & dtLastModified & "
" Response.Write "Last Accessed : " & dtLastAccessed & "

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

©2023 Copyright DevX - All Rights Reserved. Registration or use of this site constitutes acceptance of our Terms of Service and Privacy Policy.