XSLT中的日期格式

时间:2016-05-19 04:48:44

标签: xslt

我的日期格式为“2016年5月19日”,我想写一个条件,如果它是那种格式,它应该被转换为“19-May-16”。 我如何在xslt中完成它。我们很乐意快速回答。

2 个答案:

答案 0 :(得分:2)

实际上,在XSLT中这很容易做到 - 尽管有点冗长:

<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)"/>

答案 1 :(得分:1)

你需要一个扩展方法,因为在XSLT中这样做真的很难。自从我使用XSLT调解器以来已经很长时间了,如果您使用的是TBB站点中的一个,或者使用SDL Tridion 2013及更高版本附带的那个,那么您就不会说明

查看https://www.sdltridionworld.com/community/extension_overview/xsltmediator.aspx并搜索日期

http://docs.sdl.com/LiveContent/content/en-US/SDL_Tridion_2013/concept_8E74450486DE4950B81B3D83ACDDF5FA

在SDL中执行此操作的功能是<xsl:value-of select="mediator:GetFormattedDate('2012-10-08T06:30:00', 'MMMM dd, yyyy')" />

相关问题