me Banner
TECH
HARDWARE CISCO LINUX MICROSOFT C++ HTML JAVASCRIPT PERL SHELL SCRIPTING SQL NOTES

Echo DATE and TIME with SSI

To display the current date and time on your page, the following SSI code is used :
<!--#echo var="DATE_LOCAL" -->

The result will look similar to this :
Sunday, 30-Apr-2017 11:37:18 CDT

Rather long and drawn out result isn't it? No problem, there is an SSI command that will format it to your specs. This SSI code line goes just before the DATE_LOCAL one...
<!--#config timefmt="value" -->

So now your date line looks like this...
<!--#config timefmt="value" --> <!--#echo var="DATE_LOCAL" -->

This will "Configure the next SSI code into time format of this value". There are many different values to enter to get the info you want to show...
ValueDescriptionResult
%aabbreviated weekday nameSun
%Afull weekday nameSunday
%babbreviated month nameApr
%Bfull month nameApril
%Cdefault date and time format20
%dday of month - 01 to 3130
%Ddate as %m/%d/%y04/30/17
%eday of month - 1 to 3130
%Hhour - 00 to 2311
%Ihour - 01 to 1211
%jday of year - 001 to 366120
%mmonth of year - 01 to 1204
%Mminute - 00 to 5937
%pstring containing AM or PMAM
%rtime as %I:%M:%S %p11:37:18 AM
%Rtime as %H:%M11:37
%Ssecond - 00 to 5918
%Ttime as %H:%M:%S11:37:18
%yyear within century - 00 to 9917
%Yyear as CCYY (4 digits)2017
%Ztimezone nameCDT

Here are some examples with their results...

<!--#config timefmt="%m/%d/%y" --> <!--#echo var="DATE_LOCAL" -->
04/30/17

<!--#config timefmt="%H:%M:%S" --> <!--#echo var="DATE_LOCAL" -->
11:37:18

Today is <!--#config timefmt="%A" --> <!--#echo var="DATE_LOCAL" -->
Today is Sunday

The slashes, colons, spaces and commas in the timefmt value will be reflected in the resulting answer. They are considered as normal text. The % indicates the next letter represents part of the SSI date string.

Note : spacing is very crucial to having SSI work correctly. There is a space before the ending comment tag. There is also a space between the config SSI and the echo SSI commands.

Some results will vary depending on the server hosting your web page. These are based on the date and time where the host server is located, not yourself. In some cases though, it may turn out your host server is in the same timezone :)

Originally located here.

The echo command may be used to display the "last modified" date of the html document. That is the last time a specific web page was changed and/or uploaded to the server.

<!--#echo var="LAST_MODIFIED" -->

You will have to enter the correct filename and extension with this command. Since this is also a date and time command like DATE_LOCAL, you can use the config timefmt command before this one too.
<!--#config timefmt="%m/%d/%y" --> <!--#echo var="LAST_MODIFIED" -->

Now if you want to show this effect with a value from a different page, then the flastmod command may be used. flastmod stands for File Last Modified.
<!--#flastmod file="filename.shtml" -->

You will have to enter the correct filename and extension with this command. Since this is also a date and time command like DATE_LOCAL, you can use the config timefmt command before this one too.
<!--#config timefmt="%m/%d/%y" --> <!--#flastmod file="filename.shtml" -->

Originally located here.