Echoing server information such as user IP, current date etc using SSI
To echo something using SSI, the syntax is:
<!--#echo var="VARIABLE HERE" -->
Lets see how to use these variables exactly.
Echo current server date and time
To display the current server date and time, use either the "DATE_GMT" or "DATE_LOCAL" variable. In its simplest form:
<!--#echo var="DATE_LOCAL" -->
Output: Friday, 31-Oct-2014 13:53:02 MDT
Not bad eh for one simple line of code.
Echo last modified date of current document or file
It's very useful at times to show the last modified date of a web page:
This document last modified: <!--#echo var="LAST_MODIFIED" -->
Output: This document last modified: Saturday, 04-Mar-2006 01:41:24 MST
Echo last modified date of any document or file
You can also display the last modified date of any document or file on your server besides the present, by using another command called #flastmod instead of #echo:
greenday.mp3 last modified: <!--#flastmod file="grenday.mp3"--> Index page last modified: <!--#flastmod virtual="/index.html"-->
Sample output: greenday.mp3 last modified Thursday, 06-Jan-2005 05:35:27 EST.
Echoing visitor IP address
This is also a commonly requested question and answer- how to display the user's IP address:
Your IP: <!--#echo var="REMOTE_ADDR" -->
Output: Your IP: 126.96.36.199
Displaying file size of a document
Finally, you can display the file size of any document on your server using #echo, by using a different command called #fsize.
This document's file size: <!--#fsize file="current.shtml" --> The file size of main index page: <!--#fsize virtual="/index.shtml" -->
Sample output: This document's file size: 8.4K
Interesting Uses of SSI
var currentime="<!--#echo var="DATE_LOCAL" -->" var serverdate=new Date(currenttime) //rest of script
Here's a completed example.