The following model of a web page illustrates methods for doing somethings that are difficult in web pages. One is the ability to show the LAST_MODIFIED date of the file that constitutes the web page itself. You'd like the reader of the page, served up by whatever web server handles the page, like Apache, to be able to see the LAST_MODIFIED date of the file. How that can be accomplished varies by the suffix of the page. It can be .html, .shtml, or .php, and each ending has certain capabilities for doing what you want. The unfortunate thing is that .html and .shtml can both use Javascript, but a .shtml files will NOT (typically) supply the "document.lastModified" value for the file itself. Instead, the "current date/time is supplied, and that is NOT the LAST_MODIFIED date/time.
For normal .html, the server does NOT deal with SSI commands (server-side instructions). But it does send a proper LAST_MODIFIED date/time. On the other hand, .shtml files can normally have SSI commands which are handled by the server. But the server doesn't send LAST_MODIFIED. So you have this division in execution. How do you deal with BOTH in a single web page? The solution is in the first portion of the illustrated page. The SSI commands are always imbedded in comments. The third line with #config and #echo is a pair of such comments. In a .shtml file, both of these comments are executed by Apache BEFORE sending the page, and the result replaces the comments. In this case, we don't want the Javascript which follows the comments to output LAST_MODIFIED a second time.
However, if this is a normal .html file, the comments are NOT executed, and remain invisible comments. Now we want the Javascript to provide the LAST_MODIFIED date. The trick in the Javascript is to compare "document.lastModified" to the current date/time stamp BECAUSE the Javascript will use the current date/time as a substitute for the missing lastModified in a .shtml file, but in .html, it will find a proper lastModified value. So what the Javascript does is compare "now", which is current date/time in proper format, to "testlast" which is the document.lastModified value in that same format. If they are different, we display document.lastModified because we got a LAST_MODIFIED value, which implies the SSI commands were NOT handled by the server.
Yes, it's tricky, but this "Last modified:" code works properly in BOTH .html and .shtml, even if the server executes SSI commands for .html pages since it doesn't send LAST_MODIFIED in that case. You can tell which code supplied the result as follows: SSI separates with m-d-y, while Javascript separates with m/d/y.
For a .php file, it's quite simple to show the LAST_MODIFIED date:
date_default_timezone_set('America/Los_Angeles');
You may wish to change the timezone setting to your server's location. Web search for "php list of supported timezones".
After the header line, the next section shows the LAST_MODIFIED code beginning with the Last modified words, then the SSI comments, and then the Javascript equivalent. After the first <hr> is a small Javascript that outputs the domain name of the server. After the second <hr> is another example of SSI comments that display DATE_LOCAL. And immediately following that is the final section that demonstrates a "clock" that can be displayed on your page. The clock is started by the clock(0); statement within the final div-section. The parameter is any positive integer, including 0. Even numbers display 24-hour clock values, and odd numbers display 12-hour clock values with AM and PM suffixes. Both 0 and 1 are treated special in that they will flip-flop back and forth every second. Even integers 2 or greater provide just 24-hour values, and odd number 3 or greater give just 12-hour clock values. Play around with the initial parameter within the div-section. Note: you may have to refresh your page to eliminate any cached version. Also notice the php code can be included because it is ignored in non-php files, and vice-versa.
date_default_timezone_set('America/Los_Angeles');