home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference

Document.lastModified Property


Document.lastModified Property---modification date of a document


Navigator 2.0, Internet Explorer 3.0




lastModified is a read-only string property that contains the date and time at which document was most recently modified. This data is derived from HTTP header data sent by the web server. The web server generally obtains the last-modified date by examining the modification date of the file itself.

Web servers are not required to provide last-modified dates for the documents they serve. When a web server does not provide a last modification date, JavaScript assumes 0, which translates to a date of January 1st, 1970, GMT. The example below shows how you can test for this case.


It is a good idea to let readers know how recent the information you provide on the Web is. You can include an automatic time stamp in your documents by placing the following script at the end of each HTML file. By doing this you do not need to update the modification time by hand each time you make a change to the file. Note that this script tests that the supplied date is a valid one before displaying it.

if (Date.parse(document.lastModified) != 0)
    document.write('<P><HR><SMALL><I>Last modified: ' 
                   + document.lastModified
                   + '</I></SMALL>');

Previous Home Next
Document.images[] Book Index Document.linkColor

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell