W3C home > Mailing lists > Public > public-i18n-geo@w3.org > May 2003

FW: This week's Q&A

From: Richard Ishida <ishida@w3.org>
Date: Wed, 28 May 2003 19:04:10 +0100
To: <public-i18n-geo@w3.org>
Message-ID: <001501c32543$8a8da100$6501a8c0@w3c40upc3ma3j2>

From: Lloyd Honomichl [mailto:lloyd@honomichl.com] 
Sent: 26 May 2003 17:11
To: ishida@w3.org
Subject: Re: This week's Q&A

Sorry about the delay.  I missed the last call due to the arrival of  
grandchild number 2.  Besides, I should get some extra slack since  
today is a holiday in the U.S. - Memorial Day.

In any case here's my Q&A:


How do I handle date formatting in my web pages?


For static web pages there is no ideal solution.  It would be nice if  
there was
some sort of <DATE> tag that would display dates according the locale  
of the
user agent, but no such tag exists.

It is common to change date formats during localization of the pages,  
but this is
not a complete solution.  English is spoken in both the U.S. and the  
U.K. but they
use different date formats, so the language of the document is not  
sufficient to
determine the format for dates.  Multi-lingual users may potentially be

by date formats as well.  If a native Japanese speaker is reading an  
English web
page from a web site in Germany that contains the date 03/04/02 how  
will they

In such cases, it is important to use an unambiguous format.  Using ISO

8601 is
one approach.  2003-04-02 is somewhat clearer than 03/04/02.  Using an
abbreviation for the month makes it even more clear:  2003-Apr-02.

For dynamically generated web pages you can use the HTTP_ACCEPT_LANGUAGE
header to control which date format is used.  A  
discussion of how to do this would be too large for this document, but  
here are
pointers for some common environments.

Java/JSP:  Call the getLocale method of the ServletRequest or
HttpServletRequest object.  Use the returned Locale object to call  

ASP: Use Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") to get the
users preferences.  Parse the first locale from the list of accepted  
locales.  You'll
have to do your own mapping from the alphabetic locale code to a numeric
Locale Identifier.  Set Session.LCID to the resulting value.  Call  
to format the date.

Perl: Use $ENV{'HTTP_ACCEPT_LANGUAGE'} to get the preferred language.
Use POSIX:strftime to format date values.  You'll have to do your own  
of the accepted langauges value to a date format string.

Remember, even if you use one of these methods for formatting the date,
choose an unambiguous  date format to avoid the sort of problems  
above.   For Java avoid the SHORT format, which uses only numbers.  For

use vbLongDate.




On Friday, May 23, 2003, at 01:39  AM, Richard Ishida wrote:

> Hi Lloyd,
> I think you were due to submit a question this week for review by
> email.
> Do you have something ready?
> Cheers,
> RI
> ============
> Richard Ishida
> W3C
> tel: +44 1753 480 292
> http://www.w3.org/International/ http://www.w3.org/People/Ishida/
Received on Wednesday, 28 May 2003 14:04:14 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:27:59 UTC