Using SSI to Display Last Modified Time

Most of the information produced by the LastUpdated CGI program can be produced by the built-in Server Side Include commands of the Apache and NCSA Web servers.

LAST_MODIFIED Environment Variable

Environment variables can easily be displayed on a web page by using the SSI "echo" command. The following line displayes the LAST_MODIFIED variable, which contains the last modified time of this page (in a default format) as displayed by the example which follows it:

Last Modified: <!--#echo var="LAST_MODIFIED"-->

Last Modified: (none)

The FLastMod SSI Command

The last modified time of other files on the server can be displayed by the SSI "flastmod" command. The following line displayes the last modified time of the LastUpdated home page:

Home Page last updated: <!--#flastmod virtual="index.html" -->

Home Page last updated: [an error occurred while processing the directive]

The Fsize SSI Command

The size of other files on the server can be displayed by the SSI "fsize" command. The following line displayes the size of the LastUpdated home page:

Size of the Home Page: <!--#fsize virtual="index.html" -->

Size of the Home Page: [an error occurred while processing the directive]

Customizing the Format

The format of the time can be customized by using the SSI "config" command as follows:

<!--#config timefmt="%e %B %Y" -->

The format string ("%e %B %Y" in this case) uses the standard abbreviations of the C "strftime" library routine. Following is the full list of date abbreviations.

%a - abbreviated weekday name (Fri)
%A - full weekday name (Friday)
%b - abbreviated month name (Feb)
%B - full month name (February)
%c - locale's appropriate date and time representation (Fri Feb 4 15:08:02 1998)
%C - default date and time format (20)
%d - day of month - 01 to 31 (04)
%D - date as %m/%d/%y (02/04/98)
%e - day of month - 1 to 31 (single digits are preceded by a blank) ( 4)
%h - abbreviated month name (alias for %b) (Feb)
%H - hour - 00 to 23 (15)
%I - hour - 01 to 12 (03)
%j - day of year - 001 to 366 (046)
%m - month of year - 01 to 12 (02)
%M - minute - 00 to 59 (08)
%n - insert a newline character
%p - string containing AM or PM
%r - time as %I:%M:%S %p (03:08:02 PM)
%R - time as %H:%M (15:08)
%S - second - 00 to 61 (02)
%t - insert a tab character
%T - time as %H:%M:%S (15:08:02)
%U - week number of year (Sunday is the first day of the week) - 00 to 53 (05)
%w - day of week - Sunday=0 (5)
%W - week number of year (Monday is the first day of the week) - 00 to 53 (05)
%x - Country-specific date format (02/04/98)
%X - Country-specific time format (15:08:02)
%y - year within century - 00 to 99 (98)
%Y - year as CCYY - 4 digits (1998)
%Z - timezone name (EST)

The footer on this page was produced by the following text:

(<!--#echo var="SERVER_NAME" --><!--#echo var="DOCUMENT_URI" -->)<BR>
<!--#config timefmt="%e %B %Y" -->
Last updated: <!--#echo var="LAST_MODIFIED" -->, Size: <!--#fsize virtual="ssi-method.html" -->

(dionysia.org/software/lastupdated/ssi-method.html)
Last updated: (none), Size: [an error occurred while processing the directive]