【发布时间】:2011-02-21 05:57:40
【问题描述】:
我们如何在 xslt 中格式化日期?
例子:
<xsl:value-of select ="name of function(I/P, 'MMM dd, yyyy')"/>
【问题讨论】:
标签: xslt
我们如何在 xslt 中格式化日期?
例子:
<xsl:value-of select ="name of function(I/P, 'MMM dd, yyyy')"/>
【问题讨论】:
标签: xslt
这可能会有所帮助:ms:format-date Function
使用文章中的示例,您可以按如下方式格式化日期:
未编辑日期:2000-02-16T15:56:00
编辑日期:2000 年 2 月 16 日
【讨论】:
如果您使用的是 XSLT 1.0,您可能会发现 EXSLT - Date and Times 中的日期格式化功能很有用,尤其是 format-date。如果您使用的是 XSLT 2.0,则可以使用Formatting Dates and Times 中描述的内置函数。
作为后者的示例,如果您想以“2020 年 1 月 1 日”格式输出日期,您可以这样写
<xsl:value-of select="format-date($d, '[MNn,*-3] [D01], [Y0001]')"/>
【讨论】:
MMM dd, yyyy?