SSI Info
Home ] Up ]


The ECHO Directive:
Displaying the Environment in
Server Side Includes!

The ECHO directive allows you to bring it information from the environment and show it on your pages. This can allow you to show people when a page was last updated, or even to make a real back button!

Now here is something that you have probably seen on quite a few pages, the date and time. Check your watch just to make sure I'm not trying to pull one over on you. I just have to hope my server has the right system time!

The Local Time is: Thursday, 29-Jun-2017 08:50:27 UTC

The following little snippet of source code is all you need to add this feature to your page:

<B> The Local Time is
<!--#echo var="DATE_LOCAL" -->

Further down this page you can find all of the formatting commands you can use with date variables.

Making a Real Back Button
Here is a cute server side include trick, a back button that actually takes you back to where you came from.

How did the page know where you came from. Remember, we have our arsenal of server environment information and one tidbit at our disposal is HTTP_REFERER. This is the URL that brought you to this page. Here is the source code for this trick:

<A HREF="<!--#echo var="HTTP_REFERER"-->">BACK BUTTON</A>
If you came to this page directly, such as from a link in your e-mail or you hand-typed it in, then (none) would be the value for HTTP_REFERER.

Here are the other values you can let var= are:

AUTH_TYPE client authorization method if any (none)
CONTENT_LENGTH size of input posted from client (none)
CONTENT_TYPE MIME type of content (none)
DATE_LOCAL The current GMT (greenwich, UK) can be formatted using #config Thursday, 29-Jun-2017 08:50:27 UTC
DATE_LOCAL current time/date, can be formatted using #config Thursday, 29-Jun-2017 08:50:27 UTC
DOCUMENT_NAME document name that was requested ssi.htm
DOCUMENT_URI URL of the document /ssi.htm
DOCUMENT_ROOT Document root /usr/local/www/htdocs_kt2t.everything
LAST_MODIFIED document modified date, can be formatted using #config Friday, 11-Mar-2011 21:02:00 UTC
PAGE_COUNT number of accesses to current document since server was brought on line (none)
HTTP_REFERER URL of the document the client came from (none)
REMOTE_ADDR Numeric IP address of the client
REMOTE_PORT TCP port of the remote client 54788
REMOTE_HOST domain name of the client (DNS option must be active on server) (none)
REMOTE_USER ID of user, rarely ever found (none)
SERVER_NAME server hostname (i.e.,
SERVER_PORT the port used by httpd (usually 80) 80
SERVER_PROTOCOL Which version of Httpd compliance HTTP/1.0
SERVER_SOFTWARE The name of the server software, i.e., apache 1.2.5 Apache/2.4.25 (FreeBSD) OpenSSL/0.9.8za-freebsd PHP/5.6.30
TOTAL_HITS total pages served by server since brought on line (none)

You can control the exact appearence of your time and date information by setting the timefmt using a config such as the one below. Just include this config before the actual include that calls the date.
<!--#config timefmt="%m/%d/%y" -->

Will give you a date such as 02/17/97

The complete list of unix style date format codes follow:

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




My name is Michael Oliver, and I can be contacted by email here.
The current time is Thursday, 29-Jun-2017 08:50:27 UTC.
This page was last modified on Friday, 11-Mar-2011 21:02:00 UTC.
This page has received 1276 hits since December 2, 2001.