次の方法で共有


Modifying the FrontPage Date/Time Web Component

If you've ever inserted a date or time using Date and Time on the Insert menu in FrontPage, you may have wondered how you can change the date and/or time format. Well, you're not alone.  We recently had the following comment from a customer asking for just this kind of information.

I want to know the parameters that can be changed, and how to change them, such as language to use - my web server is in Germany but I want to display months in English, not German, and UK time, not German. and eg what do the following mean: s-format="%d %B %Y" and what are the options for these and other parameters.

Before I tell you how you can change the date and time formats, I should first explain that the date and time component is a server-side date and time component, which means that it displays the time on the server not the time on the client, so there's no way to specify a time zone (or in the case of the above comment, UK time instead of German time).  However, formatting is another thing altogether.  By changing the value of the s-format parameter, you can change how the date and time displays.

Let's backup a bit.  When you insert a date or time using the Date/Time Web component in FrontPage, FrontPage inserts webbot code.  This code looks somewhat like the following:

 <!--webbot bot="Timestamp" S-Type="REGENERATED" S-Format="%m/%d/%Y %I:%M %p" -->

The bot parameter specifies "Timestamp." This is what tells the FrontPage Server Extensions which Web component the webbot is using.  You can't change this parameter without completely wiping out your date or time.  (I know this seems like it should go without saying, but ... well, I've learned that almost nothing can go completely without saying.) However, the other two parameters, S-Type and S-Format, can be edited.

The S-Type parameter can have values of "EDITED" and "REGENERATED."  Other values don't necessarily break the webbot, but they also don't mean anything. These are the only values that FrontPage generates from the Date and Time dialog box, but to be completely honest, I didn't really notice a difference between the dates and/or times that these two values generate.

S-Format can have any combination of several values, and the ones that you use will affect how the date and/or time displays.  The following table provides a list of possible values and a description of each value.  (By the way, casing is critically important here.  For example, an uppercase M returns the minutes while a lowercase m returns the month.)

The examples in the following section use the following date/time as a guide:
Friday, December 17, 2004 06:29:42 PM

Parameter Value Description Example
%A Day of the week in long format. (Date) Friday
%a Day of the week in short format. (Date) Fri
%B Month spelled out in long format. (Date) December
%b Month spelled out in short format. (Date) Dec
%m Month in number format. (Date) 12
%d Day of the month. (Date) 17
%Y Year in long format. (Date) 2004
%y Year in short format. (Date) 04
%I Hour in 12-hour format. (Time) 06
%H Hour in 24-hour format. (Time) 18
%M Minutes. (Time) 29
%S Seconds. (Time) 42
%p Shows PM or AM. (Time) PM

You can create date and time formats using any combination of the above parameter values.  In addition, as long as a percent sign (%) preceeds each parameter value that indiates a date or time element, you can use extra characters, symbols, and spaces between these parameter values.  For example, you could create the date/time as shown in the example preceeding the table by using an S-Format value of "%A, %B %d, %Y %H:%M:%S %p".

Note   You can use the percent sign (%) as a symbol by placing two percent signs together (%%). The FrontPage Server Extensions see this as an escape character sequence and display a single percent sign.

Before concluding, I should note that the date and time displayed when you use the Date/Time Web component is the date and/or time a page was saved NOT the current date or time on the server or a visitor's computer.  For the current date or time, you would need to use server-side scripting, such as ASP, to get the server's date or time or client-side scripting, such as JavaScript, to get the date or time on the visitor's computer.  (For JavaScript that displays the date and/or time, see Dates, dates, and more dates...).

Comments