Reputation: 23
I have the date format coming as "19 May 2016", I want to write a condition if it's in that format , it should be converted as "19-May-16". How do i do it in xslt.Would appreciate an quick answer.
Upvotes: 1
Views: 77
Reputation: 117140
Actually, this is very easy to do in XSLT - although a bit verbose:
<xsl:value-of select="substring-before(date, ' ')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring-before(substring-after(date, ' '), ' ')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(substring-after(substring-after(date, ' '), ' '), 3, 2)"/>
Upvotes: 2
Reputation: 10163
You will need an extension method for this, as doing it in XSLT is really hard. It is a long time since I used the XSLT mediator(s), and you don't state if you are using the one from the TBB Site, or the out of thebox one that comes with SDL Tridion 2013 and higher
Take a look at https://www.sdltridionworld.com/community/extension_overview/xsltmediator.aspx and search for Date
The function to do this inside SDL is <xsl:value-of select="mediator:GetFormattedDate('2012-10-08T06:30:00', 'MMMM dd, yyyy')" />
Upvotes: 1