我有一个这种格式的日期
10/12/2011 12:55:00 PM (MM-DD-YYYY time)
我想把这个日期格式化成
12/10/2011 (DD-MM-YYYY) time to be removed
使用 XSLT?我发现的复杂性是有时输入日期可能看起来像
7/12/2011 12:55:00 PM (only one number to the front instead of 07)
有人可以告诉我实现这个的方法吗?提前谢谢了。
最佳答案
仅使用标准的 XPath 字符串函数,如 substring-before
、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)
)"/>
关于xml - XSLT 格式日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9077233/