Often on pages, it is useful to include the last date the document was updated. Often, people just manually change it every time a change is made. But why? Shouldn’t this be automatic?
For the last modified date in PHP, something like this should suffice…
echo "This page was last modified: " . date ("F d Y", filemtime(__FILE__));
You’d wanna take this date and add it to a label or something, but you’d probably use something like that…
HttpWebRequest req =(HttpWebRequest)WebRequest.Create(Path.GetFileName(request.PhysicalPath)); HttpWebResponse res =(HttpWebResponse) req.GetResponse(); DateTime abcd = res.LastModified;
Again, do what you wish with what this returns.
String lastModified = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").parse(request.getHeader("last-modified")).toString();
NOTE: For this to work in Java, your server needs to be configured to send along the last-modified header. Many servers DO NOT by default.
var lastModified = document.lastModified;