XSLT格式日期

Chi*_*hin 5 xml xslt xpath string-formatting

我有这种格式的约会

10/12/2011 12:55:00 PM (MM-DD-YYYY time)
Run Code Online (Sandbox Code Playgroud)

我想将这个日期格式化为

12/10/2011 (DD-MM-YYYY) time to be removed 
Run Code Online (Sandbox Code Playgroud)

使用XSLT?我发现的复杂性有时输入日期可能是这样的

7/12/2011 12:55:00 PM (only one number to the front instead of 07)
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我一种实现方法吗?提前谢谢了.

Kir*_*huk 4

substring-before仅使用标准 XPath 字符串函数(如、substring-after和 )即可轻松获得所需结果,substring例如:

<xsl:variable name="input">7/12/2011 12:55:00 PM</xsl:variable>

<xsl:value-of select="concat(
              substring-before(substring-after($input, '/'), '/'), '/',
              substring-before($input, '/'), '/',
              substring(substring-after(substring-after($input, '/'), '/'), 1, 4)
              )"/>
Run Code Online (Sandbox Code Playgroud)