Re: [xsl] formatting dates/times in XSL

Subject: Re: [xsl] formatting dates/times in XSL
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Tue, 30 Oct 2001 10:47:46 +0100
On Mon, Oct 29 '01 at 22:17, Todd Binder wrote:
> Is there a way to format dates and times in XSL?  currently I have date and
No, but you can easily write one
> time elements in the XML sourcefile
> 
> <date>20011011</date>
<xsl:template match="date">
  <xsl:variable name="month" select="substring(.,5,2)"/>
  <xsl:value-of 
       select="document('')//my:monthnames/my:month[position()=$month]"/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="substring(.,7,2)"/>
  <xsl:text>, </xsl:text>
  <xsl:value-of select="substring(.,1,4)"/>
</xsl:template>

with

<my:monthnames>
  <my:month>Januar</my:month>
  <my:month>Februar</my:month>
  <my:month>March</my:month>
  <!-- ... -->
  <my:month>December</my:month>
</my:monthnames>

somewhere in the beginning of your stylesheet
> <time>14:00</time>
> 
> and with XSL, I would like to format the date as MMM DD, YYYY (i.e. October
> 11, 2001) and format the time in the format of 2 pm
I will not tell you how to converte time to this wired american format, as I 
only support "military" time. (Germany and most of Europa does only use 
"military" time)
-- 
Goetz Bock                                              IT Consultant
Dipl.-Inf. Univ.

Attachment: pgp00022.pgp
Description: PGP signature

Current Thread