jc carmelo
jc carmelo

Reputation: 133

Convert date in XSL

I was wondering how can you this kind of date into a normal one.

Sample xml:

enter image description here

I want my output to be like this: 01/03/1959 based from the sample xml. I'm using xslt version 1.0 and xpath 1.0

Upvotes: 0

Views: 41

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 117073

Well, there are no dates as such in XSLT 1.0, so just threat this as an exercise in string manipulation and write out:

<xsl:value-of select="substring(data, 5, 2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(data, 7, 2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(data, 1, 4)"/>

or, if you prefer:

<xsl:value-of select="concat(substring(data, 5, 2), '/', substring(data, 7, 2), '/', substring(data, 1, 4))"/>

how can you this kind of date into a normal one.

Actually, the "normal one" would look like this: 1959-01-03.
http://en.wikipedia.org/wiki/ISO_8601

Upvotes: 2

Related Questions