|
Help
CodingForums Partners
This is a
![]() |
|
| CODE | PURPOSE OF CODE |
| %a | abbreviated weekday name |
| %A | full weekday name |
| %b | abbreviated month name |
| %B | full month name |
| %c | locale's appropriate date and time |
| %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 |
| %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 59 |
| %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 |
There are ways to customize the format of this output. Take a look at the right table, and the following examples to see how to do just that.
Code:
<!--#config timefmt="%m/%d/%y" -->
Sample output: 05/24/05
Code:
<!--#config timefmt="%H:%M:%S" -->
Sample output: 23:59:01
Code:
Today is <!--#config timefmt="%A -->
Sample output: Today is Friday
Piece of cake, right?
-Display the last modified date of a webpage
To display the last modified date of a webpage, add the following SSI code to it:
<!--#flastmod file="ssi.htm" -->
-Include a document inside another
This must be one of the most useful features of SSI- the ability to include one document inside another. The SSI code for this is:
<!--#include file="myfile.htm"-->
Put that anywhere in your webpage, and myfile.htm shows up in it's place. The file doesn't have to be a ".htm" file. It could also be a ".txt" file (ie: myfile.txt). So how is this useful? Let's say you have a peice of content that is repeated on many pages of your site (a navigational bar, for example). By saving that content as an individual html file, and using SSI instead to include that content onto those pages, updating that content becomes merely changing that ONE file. The changes is instantly reflected on all pages containing the SSI include command. The ugly alternative, again, would be to manually edit the navigational bar for each and every page containing it. On sites with hundreds or even thousands of pages, prepare to camp out in front of your computer!
-Execute a CGI script or command directly from the webpage
Last but not least, SSI allows you to execute a CGI script or command directly from the webpage. This is where SSI becomes not only handy, but critical, in many cases. It's not a feature you would use by itself, but in conjunction with a CGI script you have installed. You see, many CGI scripts require that it be called directly from the webpage, which only SSI can do. In other words, in order to get some CGI scripts to work, you must use SSI. The SSI code to call a CGI script from the webpage is:
<!--#exec cgi="/cgi-bin/myscript.cgi"-->
Of course, you'll need to change "myscript.cgi" to the script you're trying to call. Ok, so when do you need to call a CGI script, then? If and when the CGI script you're using asks for it! For example, many hit counter or stats scripts require the use of the above SSI call in order to function. Poll and survey scripts too. Just know that when the scripts says you need SSI in order to use it, it means what I'm talking about here.