I want to add the date and time the web page was last updated.
Here is the JavaScript code. I don't see why this does not work.
var lastModified = document.lastModified;
document.getElementById("modified").innerHTMLl() = lastModified;
Please help. Thanks.
As already given in the comments, there is a syntax error in the second line of the script. It should be as follows:
var lastModified = document.lastModified;
document.getElementById("modified").innerHTML = lastModified;
(note the removed l()
).
Note that while it does for a basic "last modified" display, in today's web, there are a lot of factors to consider when defining "last modified". Your approach will basically just display what the server told about the modification time in the respective HTTP header.
Consider an upload to a remote fileserver which is served to your users: Will it display the actual changed date or just the date of the upload (depends on whether the upload sets the modification time for the file as it writes it, so you'd better try out)? Is the page generated in some way? (In this case, it could very well display the time of generation instead of the actual changes).