//  home   //  advanced search   //  news   //  categories   //  sql build chart   //  downloads   //  statistics
 ASP FAQ 
Home
ASP FAQ Tutorials

   8000XXXX Errors
   Alerts
   ASP.NET 2.0
   Classic ASP 1.0
      COM / ActiveX Components
      Forms
      General Topics
      Date/Time Routines
      Email Scripts & Info
      Files/Directories & FSO
   Databases
   General Concepts
   Search Engine Optimization (SEO)

Contact Us
Site Map

Search

Web
aspfaq.com
tutorials.aspfaq.com
classicasp.aspfaq.com

ASP FAQ Tutorials :: Classic ASP 1.0 :: Date/Time Routines :: Why does JavaScript's document.lastModified() not work in ASP files?


Why does JavaScript's document.lastModified() not work in ASP files?

ASP is compiled when the user requests the file, so browsers report the time the HTML was generated, not when the ASP file was saved. Here is some code 
 
VBScript: 
 
<% 
    thisfile = Request.ServerVariables("SCRIPT_NAME") 
    thisfile = Server.MapPath(thisfile) 
    set fso = CreateObject("Scripting.FileSystemObject") 
    set fs = fso.getfile(thisfile) 
    dlm = fs.datelastmodified 
    set fs = nothing: set fso = nothing 
    Response.Write("Last modified: ") 
    Response.Write(formatdatetime(dlm,1) & " " & formatdatetime(dlm,3)) 
%>
 
JScript: 
 
<script language=jscript runat=server> 
    var thisfile = Request.ServerVariables("SCRIPT_NAME"); 
    thisfile = Server.MapPath(thisfile); 
    var fso = new ActiveXObject("Scripting.FileSystemObject"); 
    var fs = fso.GetFile(thisfile); 
    var dlm = fs.DateLastModified; 
    Response.Write("Last modified: " + dlm); 
</script>
 
Of course, when you add this script to a file and save it, the dateLastModified value will become "now()" by definition. 
 
If you have a common include file, you could put this code in THAT file without changing the calling file. See Article #2072 if you want the last modified time of the include file instead.

Related Articles

Can I get millisecond accuracy in ASP?
Can I make VBScript format dates for me?
Could I get a little help with dates?
Given a date, how do I find the beginning and end of that week?
Given two dates, how do I determine an age?
How do I calculate dates, such as the first day of the month?
How do I convert a DATEDIFF to days, hours, and minutes?
How do I convert a timespan, in seconds, to HH:MM:SS?
How do I convert local time to UTC (GMT) time?
How do I count the number of business days between two dates?
How do I delimit/format dates for database entry?
How do I determine the number of seconds since 1/1/1970?
How do I display time in military format?
How do I implement a calendar / datepicker in ASP?
How do I select time only from a DATETIME column?
Why do I have problems inserting NOW() into a database?

 

 


Created: 7/9/2000 | Last Updated: 3/24/2005 | broken links | helpful | not helpful | statistics
© Copyright 2006, UBR, Inc. All Rights Reserved. (356)

 

Copyright 1999-2006, All rights reserved.
Finding content
Finding content.  An error has occured...