About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Echo - Date & Time...

   Browse by title articles:
   What is hot:

SSI - F.A.Q.

Introduction and SSI basics

SSI Test

Include

Echo - Intro

Echo - Date & Time

Making your website fit different screen resolutions
Custom Error Messages
A Sticky Website
Navigation - What makes a good one?
 1 2Next articles



Echo - Date & Time


Computer & I'net articlesEcho - Date & Time

by David Stanley    



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 :

Wednesday, 10-Dec-2003 09:48:59 PST

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...

Value Description Result
%a abbreviated weekday name Wed
%A full weekday name Wednesday
%b abbreviated month name Dec
%B full month name December
%C default date and time format 20
%d day of month - 01 to 31 10
%D date as %m/%d/%y 12/10/03
%e day of month - 1 to 31 10
%H hour - 00 to 23 09
%I hour - 01 to 12 09
%j day of year - 001 to 366 344
%m month of year - 01 to 12 12
%M minute - 00 to 59 48
%p string containing AM or PM AM
%r time as %I:%M:%S %p 09:48:59 AM
%R time as %H:%M 09:48
%S second - 00 to 59 59
%T time as %H:%M:%S 09:48:59
%y year within century - 00 to 99 03
%Y year as CCYY (4 digits) 2003
%Z timezone name PST

Here are some examples with their results...

<!--#config timefmt="%m/%d/%y" --> <!--#echo var="DATE_LOCAL" -->
12/10/03

<!--#config timefmt="%H:%M:%S" --> <!--#echo var="DATE_LOCAL" -->
09:48:59

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

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 :)




-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.





Life insurance




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com