Availability
JavaScript 1.0
Synopsis
document.lastModifiedDescription
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-modified date, JavaScript assumes 0, which translates to a date
of midnight, January 1, 1970, GMT. The following example shows how
you can test for this case.
Example
It is a good idea to let readers know how recent the information you
provide on the Web is. You can include an automatic timestamp in your
documents by placing the following script at the end of each HTML
file. Doing this means 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 valid before displaying it:
<script>
if (Date.parse(document.lastModified) != 0)
document.write('<p><hr><small><i>Last modified: '
+ document.lastModified
+ '</i></small>');
</script>
See Also
The Document location,
referrer, and title properties