Quantcast
Channel: Formatting date in xslt - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by MiMo for Formatting date in xslt

$
0
0

You can use a combination of substring-after and substring-before to extract the pieces, and then handle them as numbers instead than strings - i.e. uses multiplications and additions to generate the final value.

Something like this:

<xsl:variable name="sep" select="'-'"/><xsl:variable name="date" select="."/><xsl:value-of select="substring-after(substring-after($date, $sep),$sep) + substring-before(substring-after($date, $sep),$sep)*100 + substring-before($date, $sep)*10000"/>

setting the sep and date variables to the separator to use and the original date string respectively (in your question the sample uses - as the separator, but the XSLT uses /)


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>