[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Converting date formats

Subject: RE: Converting date formats
From: Xiaocun Xu <xiaocunxu@xxxxxxxxx>
Date: Thu, 7 Jun 2001 12:55:50 -0700 (PDT)
converting date
Hi, Doug:

  If you are new to XSLT, you really should start by
going through a primer before trying to code anything
productive.  If you have any question, check out FAQ
at http://www.laidback.org/dpawson/xsl/xslfaq.html
first.
  In any case, here is a complete working XSL
illustrate date formatting.  I set current date into a
variable and output it in the format you wanted.  This
is a good start point for you to massage this code
into your own code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:template match="/">	
    <xsl:variable name="date" select="20010607"/>
    <xsl:value-of select="concat(substring($date, 7,
2),'/',substring($date, 5, 2),'/',substring($date, 1,
4))"/>
  </xsl:template>
</xsl:stylesheet>

Hope this helps,
Xiaocun

--- "Hewko, Doug" <Doug.Hewko@xxxxxxxxxxxxxxx> wrote:
> Thanks for the help. Do you have an example? I am
> very new to XML (just
> starting to learn even what a DTD is for) and am
> unable to get the previous
> suggestions to work. When I entered the
> "xsl:variable" solution, I got a
> "can not use xsl:variable there" type message.
> 
> -----Original Message-----
> From: Gary Frederick
> [mailto:gary.frederick@xxxxxxxxx]
> Sent: June 7, 2001 2:41 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Converting date formats
> 
> 
> Others gave the direct way to translate dates. You
> can also use the XSLT 
> Standard Library
>    http://xsltsl.sourceforge.net/
> 
> =====
> I use it to print events for a calendar. The input
> is iCalendar 
> converted to XML.
> 
> ...
> <DTSTART>
>    <param kind="TZID">CT(America/Chicago)</param>
>    <value>20010609T090000</value>
> </DTSTART>
> 
> 
> The stylesheet parts are
> ...
> <xsl:call-template name="DATE">
>    <xsl:with-param name="this-date"
> select="DTSTART/value"/>
> </xsl:call-template>
> ...
> <xsl:template name="DATE">
>    <xsl:param name="this-date"/>
> 
>    <xsl:call-template name="dt:format-date-time">
>      <xsl:with-param name="year"
> select='substring($this-date, 1, 4)' />
>      <xsl:with-param name="month"
> select='substring($this-date, 5, 2)'/>
>      <xsl:with-param name="day"
> select='substring($this-date, 7, 2)'/>
>      <xsl:with-param name="hour"
> select='substring($this-date, 10, 2)'/>
>      <xsl:with-param name="minute"
> select='substring($this-date, 12, 2)'/>
>      <xsl:with-param name="second"
> select='substring($this-date, 14, 2)'/>
>      <xsl:with-param
> name="time-zone"></xsl:with-param>
>      <xsl:with-param name="format"
> select="'%Y-%m-%dT %H:%M:%S'" />
>    </xsl:call-template>
> </xsl:template>
> 
> 
> 
> It's overkill if you just want to convert the date.
> Perhaps you want to 
> format dates in several ways...
> 
> Gary
> 
> 
> Hewko, Doug wrote:
> 
> > In my XML document, I have a date stored in ISO
> format:
> > <LASTUPDATED
> FORMAT="ISODATE">20010125</LASTUPDATED>
> > 
> > How can I convert this in my XSL file to dd/mm/yyy
> format (with the
> dashes)?
> > 
> > I am currently using the command:
> > 			<td><xsl:value-of select="LASTUPDATED"/></td>
> > 
> > 
> > 
> >  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.