Server Side Includes
My understanding so far...
The default SSI date reporting format is: Saturday, 05-Dec-2020 09:32:34 EST before you specify a format.
There is a Server Side Include (SSI) directive working in the code of this page to put the day and date into the boxed line just above. This version is formatted to show the date with fully spelled out names of day, month and the full four-digit year.
A typical SSI entry for a date and time, like the code displayed below has two parts: a configuration or format for the date, and an echo of the date information using that format. Each directive is set off in an html comment. The format looks like this:
<p style="font-weight:bold">Today is <!--#config timefmt="%A, %B %d, %Y" --> <!--#echo var="DATE_LOCAL" --></p>
I hope you noticed that the information is accurate for today as you access this page. SSI updates the page as needed.
Check the time listed here: 09:32:34 ... Wait a bit ... Refresh the page and check the time. If you waited long enough, the minute value changed. Cool! (The time is for the server, in this case a Central US timezone, which may not match your local time.)
For Greenwich Mean Time: 14:32:34 the code is: <!--#config timefmt="%H:%M:%S"--><!--#echo var="DATE_GMT"-->
Server side Include code can be embedded wherever we need to see the day/date/time information. It will be correct, assuming that the server operator has been vigilant to keep the server's clock correct. Fortunately most people who set up web servers have set the server to get its clock information from the standard time servers out on the Internet. Being synchronized is important in networked systems.
Some of the other common SSI directives do not need a format component. The next paragraph is "included" from an external file by using this short SSI directive: <!--#include file="inside.html"-->
The text and style formatting of a separate file have been inserted into the current page using a Server Side Include directive. SSI seems to be an early method for building dynamic web pages.
#flastmod (file last modified <!--#flastmod virtual="index.html"-->) is the SSI directive which picks up the modification date for any file on the server. The "virtual" component says you have access to any file on the server, not just in the immediate directory.
By using a slash, you can make the SSI start from the site's root directory <!--#flastmod virtual="/index.html"--> so that this version would show the date of the main index.html file instead of the one in the local directory.
If you used "file" instead, the file would have to be in the same directory as this page file (or in a subdirectory of the current location). To show the modification date of the index.html file, just enter the following short code into the paragraph where you want it: <!--#flastmod file="index.html"-->.
<!--#config timefmt="%A, %B %d, %Y (%H:%M:%S)" --><!--#flastmod file="index.html"-->You get this: Friday, June 17, 2016 (11:11:37) which is the day, date and time the index file in this programming directory was last modified. You should see that you can insert characters like the parentheses into the #config part.
Be alert. The most recent time format is in effect. Initially, I did not specify a format for this and it repeated the hour:minute:second layout from the preceding time directive. I had to add a more appropriate format to work with the #flastmod directive.
Another point to note, while developing the page, it had to be repeatedly transferred to the server. Trying to test SSI directives doesn't work when just opening a web file from your own local drive.
One practical application for SSI might be a page with a list of important files on a server which shows their last modification date. Paying attention to the age of pages can help me decide where to focus my next effort. Not all files need to be "New, new, NEW!" but they probably need occasional attention.
The formats shown below, which are then used in the following table, have lower case configuration formats for the day and month. The code %a produces a shortened day name like Sat while the %A format displays the full day name: Saturday. You'll notice the formats used here include the time as well, shown in the 24 hour clock way using %H, and %M.
<td>/programming/index.html <!-- #config timefmt="%a, %b %d, %Y - %H:%M" -->>/td> <td style="background:#f9f9ff"> <!--#flastmod virtual="/programming/index.html" --> </td> </tr>
|File Name||Last Modified|
|/index.html|| Sun, Nov 29, 2020 - 09:25
Note: If you change the name of a file as was done here for the site's main index file, you will get an error message.
|/programming/index.html||Fri, Jun 17, 2016 - 11:11|
Site Updates is a live example of the files I want to watch to have a sense of the "currency" of the site.
The server must have Server Side Includes active. The fact that you are able to see SSI results in this page indicates that my web host, Hostway, has SSI set up on the server instance allocated to me. Look closely to note that the file extension isn't the standard file.html. It is instead file.shtml so that the server knows there are SSI directives in it.
HTML Goodies Tutorial from which this page was developed
SSI information for the popular Apache Web Server
Time Format Codes
Document Object Model
Local Time - To put a person's local computer system time on your web page.